From c868cd6036a65970cfa5d0bb61e7d2b235b5a533 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 4 Jun 2020 10:53:59 +0400 Subject: [PATCH 01/10] Update lib_ui. --- Telegram/SourceFiles/chat_helpers/message_field.cpp | 13 ++++++++----- Telegram/SourceFiles/ui/empty_userpic.cpp | 2 +- .../window/themes/window_theme_preview.cpp | 2 +- Telegram/lib_ui | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Telegram/SourceFiles/chat_helpers/message_field.cpp b/Telegram/SourceFiles/chat_helpers/message_field.cpp index 215932831..67f4d2ed8 100644 --- a/Telegram/SourceFiles/chat_helpers/message_field.cpp +++ b/Telegram/SourceFiles/chat_helpers/message_field.cpp @@ -38,6 +38,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace { +using namespace Ui::Text; + using EditLinkAction = Ui::InputField::EditLinkAction; using EditLinkSelection = Ui::InputField::EditLinkSelection; @@ -298,7 +300,7 @@ bool HasSendText(not_null field) { if (code != ' ' && code != '\n' && code != '\r' - && !chReplacedBySpace(code)) { + && !IsReplacedBySpace(code)) { return true; } } @@ -585,13 +587,14 @@ void MessageLinksParser::parse() { const QChar *domainEnd = start + m.capturedEnd(), *p = domainEnd; for (; p < end; ++p) { QChar ch(*p); - if (chIsLinkEnd(ch)) break; // link finished - if (chIsAlmostLinkEnd(ch)) { + if (IsLinkEnd(ch)) { + break; // link finished + } else if (IsAlmostLinkEnd(ch)) { const QChar *endTest = p + 1; - while (endTest < end && chIsAlmostLinkEnd(*endTest)) { + while (endTest < end && IsAlmostLinkEnd(*endTest)) { ++endTest; } - if (endTest >= end || chIsLinkEnd(*endTest)) { + if (endTest >= end || IsLinkEnd(*endTest)) { break; // link finished at p } p = endTest; diff --git a/Telegram/SourceFiles/ui/empty_userpic.cpp b/Telegram/SourceFiles/ui/empty_userpic.cpp index 11a703cf8..fdff7bf88 100644 --- a/Telegram/SourceFiles/ui/empty_userpic.cpp +++ b/Telegram/SourceFiles/ui/empty_userpic.cpp @@ -267,7 +267,7 @@ void EmptyUserpic::fillString(const QString &name) { } } else if (!letterFound && ch->isLetterOrNumber()) { letterFound = true; - if (ch + 1 != end && chIsDiac(*(ch + 1))) { + if (ch + 1 != end && Ui::Text::IsDiac(*(ch + 1))) { letters.push_back(QString(ch, 2)); levels.push_back(level); ++ch; diff --git a/Telegram/SourceFiles/window/themes/window_theme_preview.cpp b/Telegram/SourceFiles/window/themes/window_theme_preview.cpp index f8a43ab6f..6470efec0 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_preview.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_preview.cpp @@ -41,7 +41,7 @@ QString fillLetters(const QString &name) { } } else if (!letterFound && ch->isLetterOrNumber()) { letterFound = true; - if (ch + 1 != end && chIsDiac(*(ch + 1))) { + if (ch + 1 != end && Ui::Text::IsDiac(*(ch + 1))) { letters.push_back(QString(ch, 2)); levels.push_back(level); ++ch; diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 62feafef7..d71d2121b 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 62feafef7ebba8df227904759f7f5684f35cb4d3 +Subproject commit d71d2121b1ffc10d2c5565d911bfa31a505d343a From f581a15b6ee03577f925a747832151849f4cfb04 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 4 Jun 2020 11:00:59 +0400 Subject: [PATCH 02/10] Fix crash in PiP window. --- Telegram/SourceFiles/media/view/media_view_pip.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Telegram/SourceFiles/media/view/media_view_pip.cpp b/Telegram/SourceFiles/media/view/media_view_pip.cpp index 1475f1000..4fb4baeb5 100644 --- a/Telegram/SourceFiles/media/view/media_view_pip.cpp +++ b/Telegram/SourceFiles/media/view/media_view_pip.cpp @@ -847,6 +847,9 @@ void Pip::setupPanel() { return _instance.info().video.size; } const auto media = _data->activeMediaView(); + if (media) { + media->goodThumbnailWanted(); + } const auto good = media ? media->goodThumbnail() : nullptr; const auto original = good ? good->size() : _data->dimensions; return original.isEmpty() ? QSize(1, 1) : original; @@ -1387,6 +1390,9 @@ QImage Pip::videoFrame(const FrameRequest &request) const { : _data->inlineThumbnailBytes().isEmpty() ? nullptr : _data->createMediaView(); + if (use) { + use->goodThumbnailWanted(); + } const auto good = use ? use->goodThumbnail() : nullptr; const auto thumb = use ? use->thumbnail() : nullptr; const auto blurred = use ? use->thumbnailInline() : nullptr; From bfafdd5b38cf4e1698cc515cf8ed1d882bed9f6e Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 4 Jun 2020 12:16:44 +0400 Subject: [PATCH 03/10] Fix crash in streaming+loading of a document. --- Telegram/SourceFiles/storage/streamed_file_downloader.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Telegram/SourceFiles/storage/streamed_file_downloader.cpp b/Telegram/SourceFiles/storage/streamed_file_downloader.cpp index bf576c84e..d84f897b9 100644 --- a/Telegram/SourceFiles/storage/streamed_file_downloader.cpp +++ b/Telegram/SourceFiles/storage/streamed_file_downloader.cpp @@ -65,6 +65,8 @@ StreamedFileDownloader::StreamedFileDownloader( StreamedFileDownloader::~StreamedFileDownloader() { if (!_finished) { cancel(); + } else { + _reader->cancelForDownloader(this); } } From bf06d4d545cb14dbf52bd2c04bbcf7aa7bad0007 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 4 Jun 2020 12:16:56 +0400 Subject: [PATCH 04/10] Fix crash in stickers box. --- Telegram/SourceFiles/boxes/stickers_box.cpp | 26 ++++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp index ccd15dfd9..9e28c43d5 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.cpp +++ b/Telegram/SourceFiles/boxes/stickers_box.cpp @@ -1921,20 +1921,28 @@ void StickersBox::Inner::readVisibleSets() { int rowFrom = floorclamp(itemsVisibleTop, _rowHeight, 0, _rows.size()); int rowTo = ceilclamp(itemsVisibleBottom, _rowHeight, 0, _rows.size()); for (int i = rowFrom; i < rowTo; ++i) { - if (!_rows[i]->unread) { + const auto row = _rows[i].get(); + if (!row->unread) { continue; } - if (i * _rowHeight < itemsVisibleTop || (i + 1) * _rowHeight > itemsVisibleBottom) { + if ((i * _rowHeight < itemsVisibleTop) + || ((i + 1) * _rowHeight > itemsVisibleBottom)) { continue; } - const auto thumbnailLoading = _rows[i]->set->hasThumbnail() - ? _rows[i]->set->thumbnailLoading() - : _rows[i]->sticker - ? ((_rows[i]->stickerMedia && _rows[i]->stickerMedia->loaded()) - || _rows[i]->sticker->thumbnailLoading()) + const auto thumbnailLoading = row->set->hasThumbnail() + ? row->set->thumbnailLoading() + : row->sticker + ? row->sticker->thumbnailLoading() : false; - if (!thumbnailLoading || _rows[i]->stickerMedia->loaded()) { - _session->api().readFeaturedSetDelayed(_rows[i]->set->id); + const auto thumbnailLoaded = row->set->hasThumbnail() + ? (row->thumbnailMedia + && (row->thumbnailMedia->image() + || !row->thumbnailMedia->content().isEmpty())) + : row->sticker + ? (row->stickerMedia && row->stickerMedia->loaded()) + : true; + if (!thumbnailLoading || thumbnailLoaded) { + _session->api().readFeaturedSetDelayed(row->set->id); } } } From 6bc7fa9ef4b049266b4fc8872f0797a8e7a51e6b Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 4 Jun 2020 12:22:37 +0400 Subject: [PATCH 05/10] Fix crash in saving of a document. --- Telegram/SourceFiles/data/data_document.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/data/data_document.cpp b/Telegram/SourceFiles/data/data_document.cpp index a9c63dfbc..c7efb41c1 100644 --- a/Telegram/SourceFiles/data/data_document.cpp +++ b/Telegram/SourceFiles/data/data_document.cpp @@ -913,7 +913,7 @@ void DocumentData::save( const QString &toFile, LoadFromCloudSetting fromCloud, bool autoLoading) { - if (const auto media = activeMediaView(); media->loaded(true)) { + if (const auto media = activeMediaView(); media && media->loaded(true)) { auto &l = location(true); if (!toFile.isEmpty()) { if (!media->bytes().isEmpty()) { From fbb2bae99fd37b2b970760f0317392509923fe0c Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 4 Jun 2020 13:24:38 +0400 Subject: [PATCH 06/10] Fix crash in OS X 10.10 / 10.11. --- Telegram/lib_ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/lib_ui b/Telegram/lib_ui index d71d2121b..5429c4c53 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit d71d2121b1ffc10d2c5565d911bfa31a505d343a +Subproject commit 5429c4c53e646e2716a2fb9a6d1ac45d0e12b082 From e1d36cfd5051d74c784c69c9f65165d4cb72b9ec Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 4 Jun 2020 16:35:26 +0400 Subject: [PATCH 07/10] Fix crash in the EditCaptionBox. --- .../SourceFiles/boxes/edit_caption_box.cpp | 119 ++++++++---------- Telegram/SourceFiles/boxes/edit_caption_box.h | 1 - 2 files changed, 54 insertions(+), 66 deletions(-) diff --git a/Telegram/SourceFiles/boxes/edit_caption_box.cpp b/Telegram/SourceFiles/boxes/edit_caption_box.cpp index d308434cb..9b8c7411f 100644 --- a/Telegram/SourceFiles/boxes/edit_caption_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_caption_box.cpp @@ -72,31 +72,21 @@ EditCaptionBox::EditCaptionBox( _isAllowedEditMedia = item->media()->allowsEditMedia(); _isAlbum = !item->groupId().empty(); - QSize dimensions; - auto image = (Image*)nullptr; - + auto dimensions = QSize(); const auto media = item->media(); if (const auto photo = media->photo()) { _photoMedia = photo->createMediaView(); _photoMedia->wanted(PhotoSize::Large, _msgId); - image = _photoMedia->image(PhotoSize::Large); - if (!image) { - image = _photoMedia->image(PhotoSize::Thumbnail); - if (!image) { - image = _photoMedia->image(PhotoSize::Small); - if (!image) { - image = _photoMedia->thumbnailInline(); - } - } - } dimensions = _photoMedia->size(PhotoSize::Large); + if (dimensions.isEmpty()) { + dimensions = QSize(1, 1); + } _photo = true; } else if (const auto document = media->document()) { _documentMedia = document->createMediaView(); _documentMedia->thumbnailWanted(_msgId); - image = _documentMedia->thumbnail(); - dimensions = image - ? image->size() + dimensions = _documentMedia->thumbnail() + ? _documentMedia->thumbnail()->size() : document->dimensions; if (document->isAnimation()) { _gifw = style::ConvertScale(document->dimensions.width()); @@ -107,24 +97,42 @@ EditCaptionBox::EditCaptionBox( } else { _doc = true; } + } else { + Unexpected("Photo or document should be set."); } const auto editData = PrepareEditText(item); - if (!_animated - && (dimensions.isEmpty() - || _documentMedia - || (!_photoMedia && !image))) { - if (!image) { - _thumbw = 0; + const auto computeImage = [=] { + if (_documentMedia) { + return _documentMedia->thumbnail(); + } else if (const auto large = _photoMedia->image(PhotoSize::Large)) { + return large; + } else if (const auto thumbnail = _photoMedia->image( + PhotoSize::Thumbnail)) { + return thumbnail; + } else if (const auto small = _photoMedia->image(PhotoSize::Small)) { + return small; } else { - const auto tw = image->width(), th = image->height(); + return _photoMedia->thumbnailInline(); + } + }; + + if (!_animated && _documentMedia) { + if (dimensions.isEmpty()) { + _thumbw = 0; + _thumbnailImageLoaded = true; + } else { + const auto tw = dimensions.width(), th = dimensions.height(); if (tw > th) { _thumbw = (tw * st::msgFileThumbSize) / th; } else { _thumbw = st::msgFileThumbSize; } - _thumbnailImage = image; _refreshThumbnail = [=] { + const auto image = computeImage(); + if (!image) { + return; + } const auto options = Images::Option::Smooth | Images::Option::RoundedSmall | Images::Option::RoundedTopLeft @@ -138,7 +146,9 @@ EditCaptionBox::EditCaptionBox( options, st::msgFileThumbSize, st::msgFileThumbSize)); + _thumbnailImageLoaded = true; }; + _refreshThumbnail(); } if (_documentMedia) { @@ -151,13 +161,7 @@ EditCaptionBox::EditCaptionBox( _isAudio = document->isVoiceMessage() || document->isAudioFile(); } - if (_refreshThumbnail) { - _refreshThumbnail(); - } } else { - if (!image && !_photoMedia) { - image = Image::BlankMedia(); - } auto maxW = 0, maxH = 0; const auto limitW = st::sendMediaPreviewSize; auto limitH = std::min(st::confirmMaxHeight, _gifh ? _gifh : INT_MAX); @@ -175,35 +179,38 @@ EditCaptionBox::EditCaptionBox( maxH = limitH; } } - _thumbnailImage = image; _refreshThumbnail = [=] { + const auto image = computeImage(); + const auto use = image ? image : Image::BlankMedia().get(); const auto options = Images::Option::Smooth | Images::Option::Blurred; - _thumb = image->pixNoCache( + _thumb = use->pixNoCache( maxW * cIntRetinaFactor(), maxH * cIntRetinaFactor(), options, maxW, maxH); + _thumbnailImageLoaded = true; }; prepareStreamedPreview(); } else { + Assert(_photoMedia != nullptr); + maxW = dimensions.width(); maxH = dimensions.height(); - _thumbnailImage = image; _refreshThumbnail = [=] { - const auto photo = _photoMedia - ? _photoMedia->image(Data::PhotoSize::Large) - : nullptr; + const auto image = computeImage(); + const auto photo = _photoMedia->image(Data::PhotoSize::Large); const auto use = photo ? photo - : _thumbnailImage - ? _thumbnailImage + : image + ? image : Image::BlankMedia().get(); const auto options = Images::Option::Smooth - | ((_photoMedia && !photo) - ? Images::Option::Blurred - : Images::Option(0)); + | (photo + ? Images::Option(0) + : Images::Option::Blurred); + _thumbnailImageLoaded = (photo != nullptr); _thumb = use->pixNoCache( maxW * cIntRetinaFactor(), maxH * cIntRetinaFactor(), @@ -276,35 +283,17 @@ EditCaptionBox::EditCaptionBox( scaleThumbDown(); } Assert(_animated || _photo || _doc); + Assert(_thumbnailImageLoaded || _refreshThumbnail); - _thumbnailImageLoaded = _photoMedia - ? (_photoMedia->image(Data::PhotoSize::Large) != nullptr) - : _thumbnailImage - ? true - : _documentMedia - ? !_documentMedia->owner()->hasThumbnail() - : true; if (!_thumbnailImageLoaded) { subscribe(_controller->session().downloaderTaskFinished(), [=] { - if (_thumbnailImageLoaded) { + if (_thumbnailImageLoaded + || (_photoMedia && !_photoMedia->image(PhotoSize::Large)) + || (_documentMedia && !_documentMedia->thumbnail())) { return; - } else if (!_thumbnailImage - && _photoMedia - && _photoMedia->image(PhotoSize::Large)) { - _thumbnailImage = _photoMedia->image(PhotoSize::Large); - } else if (!_thumbnailImage - && _documentMedia - && _documentMedia->owner()->hasThumbnail()) { - _thumbnailImage = _documentMedia->thumbnail(); - } - if (_thumbnailImage) { - _thumbnailImageLoaded = !_photoMedia - || _photoMedia->image(PhotoSize::Large); - if (_thumbnailImageLoaded) { - _refreshThumbnail(); - update(); - } } + _refreshThumbnail(); + update(); }); } _field.create( diff --git a/Telegram/SourceFiles/boxes/edit_caption_box.h b/Telegram/SourceFiles/boxes/edit_caption_box.h index c7c5bebb2..a786377fd 100644 --- a/Telegram/SourceFiles/boxes/edit_caption_box.h +++ b/Telegram/SourceFiles/boxes/edit_caption_box.h @@ -108,7 +108,6 @@ private: FullMsgId _msgId; std::shared_ptr _photoMedia; std::shared_ptr _documentMedia; - Image *_thumbnailImage = nullptr; bool _thumbnailImageLoaded = false; Fn _refreshThumbnail; bool _animated = false; From 2b9e4a8ddfed1e335619fed5bc40512b63249ce4 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 4 Jun 2020 17:26:06 +0400 Subject: [PATCH 08/10] Simplify playing video tracking (and fix a crash). --- .../SourceFiles/boxes/auto_download_box.cpp | 4 +- Telegram/SourceFiles/data/data_session.cpp | 45 +++++-------------- Telegram/SourceFiles/data/data_session.h | 6 +-- .../SourceFiles/history/history_widget.cpp | 2 - .../view/media/history_view_contact.cpp | 8 ++++ .../history/view/media/history_view_contact.h | 9 +--- .../history/view/media/history_view_game.h | 4 +- .../history/view/media/history_view_gif.cpp | 19 +++----- .../history/view/media/history_view_gif.h | 2 +- .../view/media/history_view_location.cpp | 8 ++++ .../view/media/history_view_location.h | 8 +--- .../history/view/media/history_view_media.h | 3 +- .../view/media/history_view_media_grouped.cpp | 14 +++--- .../view/media/history_view_media_grouped.h | 2 +- .../view/media/history_view_web_page.h | 4 +- 15 files changed, 53 insertions(+), 85 deletions(-) diff --git a/Telegram/SourceFiles/boxes/auto_download_box.cpp b/Telegram/SourceFiles/boxes/auto_download_box.cpp index 6b4ff9d48..b7bf9915a 100644 --- a/Telegram/SourceFiles/boxes/auto_download_box.cpp +++ b/Telegram/SourceFiles/boxes/auto_download_box.cpp @@ -216,11 +216,11 @@ void AutoDownloadBox::setupContent() { _session->data().photoLoadSettingsChanged(); } if (ranges::find_if(allowMoreTypes, _1 != Type::Photo) - != allowMoreTypes.end()) { + != allowMoreTypes.end()) { _session->data().documentLoadSettingsChanged(); } if (less) { - _session->data().checkPlayingVideoFiles(); + _session->data().checkPlayingAnimations(); } closeBox(); }); diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index dfb4db597..64fddfbe5 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -3224,43 +3224,19 @@ void Session::unregisterContactItem( } } -void Session::registerPlayingVideoFile(not_null view) { - if (++_playingVideoFiles[view] == 1) { - registerHeavyViewPart(view); - } -} - -void Session::unregisterPlayingVideoFile(not_null view) { - const auto i = _playingVideoFiles.find(view); - if (i != _playingVideoFiles.end()) { - if (!--i->second) { - _playingVideoFiles.erase(i); - view->checkHeavyPart(); - } - } else { - view->checkHeavyPart(); - } -} - -void Session::stopPlayingVideoFiles() { - for (const auto &[view, count] : base::take(_playingVideoFiles)) { +void Session::checkPlayingAnimations() { + auto check = base::flat_set>(); + for (const auto view : _heavyViewParts) { if (const auto media = view->media()) { - media->stopAnimation(); - } - } -} - -void Session::checkPlayingVideoFiles() { - const auto old = base::take(_playingVideoFiles); - for (const auto &[view, count] : old) { - if (const auto media = view->media()) { - if (const auto left = media->checkAnimationCount()) { - _playingVideoFiles.emplace(view, left); - registerHeavyViewPart(view); - continue; + if (const auto document = media->getDocument()) { + if (document->isAnimation() || document->isVideoFile()) { + check.emplace(view); + } } } - view->checkHeavyPart(); + } + for (const auto view : check) { + view->media()->checkAnimation(); } } @@ -3355,7 +3331,6 @@ void Session::registerItemView(not_null view) { } void Session::unregisterItemView(not_null view) { - Expects(!_playingVideoFiles.contains(view)); Expects(!_heavyViewParts.contains(view)); const auto i = _views.find(view->data()); diff --git a/Telegram/SourceFiles/data/data_session.h b/Telegram/SourceFiles/data/data_session.h index 6f3ac2e83..33629cd9a 100644 --- a/Telegram/SourceFiles/data/data_session.h +++ b/Telegram/SourceFiles/data/data_session.h @@ -613,10 +613,7 @@ public: UserId contactId, not_null item); - void registerPlayingVideoFile(not_null view); - void unregisterPlayingVideoFile(not_null view); - void checkPlayingVideoFiles(); - void stopPlayingVideoFiles(); + void checkPlayingAnimations(); HistoryItem *findWebPageItem(not_null page) const; QString findContactPhone(not_null contact) const; @@ -958,7 +955,6 @@ private: std::unordered_map< UserId, base::flat_set>> _contactViews; - base::flat_map, int> _playingVideoFiles; base::flat_set> _webpagesUpdated; base::flat_set> _gamesUpdated; diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 7df52c296..e72ccd0f6 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -1726,8 +1726,6 @@ void HistoryWidget::showHistory( cancelTypingAction(); } - session().data().stopPlayingVideoFiles(); - clearReplyReturns(); if (_history) { if (Ui::InFocusChain(_list)) { diff --git a/Telegram/SourceFiles/history/view/media/history_view_contact.cpp b/Telegram/SourceFiles/history/view/media/history_view_contact.cpp index 602b6e18f..5256e0fc7 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_contact.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_contact.cpp @@ -229,4 +229,12 @@ TextState Contact::textState(QPoint point, StateRequest request) const { return result; } +void Contact::unloadHeavyPart() { + _userpic = nullptr; +} + +bool Contact::hasHeavyPart() const { + return (_userpic != nullptr); +} + } // namespace HistoryView diff --git a/Telegram/SourceFiles/history/view/media/history_view_contact.h b/Telegram/SourceFiles/history/view/media/history_view_contact.h index 6dce7c858..291035b0d 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_contact.h +++ b/Telegram/SourceFiles/history/view/media/history_view_contact.h @@ -59,13 +59,8 @@ public: // Should be called only by Data::Session. void updateSharedContactUserId(UserId userId) override; - void unloadHeavyPart() override { - _userpic = nullptr; - } - - bool hasHeavyPart() const override { - return (_userpic != nullptr); - } + void unloadHeavyPart() override; + bool hasHeavyPart() const override; private: QSize countOptimalSize() override; diff --git a/Telegram/SourceFiles/history/view/media/history_view_game.h b/Telegram/SourceFiles/history/view/media/history_view_game.h index 892609b48..ce7d525b7 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_game.h +++ b/Telegram/SourceFiles/history/view/media/history_view_game.h @@ -56,8 +56,8 @@ public: void stopAnimation() override { if (_attach) _attach->stopAnimation(); } - int checkAnimationCount() override { - return _attach ? _attach->checkAnimationCount() : 0; + void checkAnimation() override { + if (_attach) _attach->checkAnimation(); } not_null game() { diff --git a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp index 47a1b6582..b66f21b45 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp @@ -1375,7 +1375,7 @@ void Gif::playAnimation(bool autoplay) { stopAnimation(); } else if (_dataMedia->canBePlayed()) { if (!autoplayEnabled()) { - history()->owner().checkPlayingVideoFiles(); + history()->owner().checkPlayingAnimations(); } createStreamedPlayer(); } @@ -1432,12 +1432,11 @@ void Gif::checkStreamedIsStarted() const { void Gif::setStreamed(std::unique_ptr value) { const auto removed = (_streamed && !value); const auto set = (!_streamed && value); - if (removed) { - history()->owner().unregisterPlayingVideoFile(_parent); - } _streamed = std::move(value); if (set) { - history()->owner().registerPlayingVideoFile(_parent); + history()->owner().registerHeavyViewPart(_parent); + } else if (removed) { + _parent->checkHeavyPart(); } } @@ -1489,14 +1488,10 @@ void Gif::stopAnimation() { } } -int Gif::checkAnimationCount() { - if (!_streamed) { - return 0; - } else if (autoplayEnabled()) { - return 1; +void Gif::checkAnimation() { + if (_streamed && !autoplayEnabled()) { + stopAnimation(); } - stopAnimation(); - return 0; } float64 Gif::dataProgress() const { diff --git a/Telegram/SourceFiles/history/view/media/history_view_gif.h b/Telegram/SourceFiles/history/view/media/history_view_gif.h index 723cc836c..4ac8342a5 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_gif.h +++ b/Telegram/SourceFiles/history/view/media/history_view_gif.h @@ -87,7 +87,7 @@ public: StateRequest request) const override; void stopAnimation() override; - int checkAnimationCount() override; + void checkAnimation() override; TextWithEntities getCaption() const override { return _caption.toTextWithEntities(); diff --git a/Telegram/SourceFiles/history/view/media/history_view_location.cpp b/Telegram/SourceFiles/history/view/media/history_view_location.cpp index 93080b164..ece2a3e94 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_location.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_location.cpp @@ -58,6 +58,14 @@ Location::~Location() { } } +void Location::unloadHeavyPart() { + _media = nullptr; +} + +bool Location::hasHeavyPart() const { + return (_media != nullptr); +} + void Location::ensureMediaCreated() const { if (_media) { return; diff --git a/Telegram/SourceFiles/history/view/media/history_view_location.h b/Telegram/SourceFiles/history/view/media/history_view_location.h index db7fe50ef..1cfe60641 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_location.h +++ b/Telegram/SourceFiles/history/view/media/history_view_location.h @@ -58,12 +58,8 @@ public: return isBubbleBottom(); } - void unloadHeavyPart() override { - _media = nullptr; - } - bool hasHeavyPart() const override { - return (_media != nullptr); - } + void unloadHeavyPart() override; + bool hasHeavyPart() const override; private: void ensureMediaCreated() const; diff --git a/Telegram/SourceFiles/history/view/media/history_view_media.h b/Telegram/SourceFiles/history/view/media/history_view_media.h index 179e3f35e..52a8155a8 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_media.h +++ b/Telegram/SourceFiles/history/view/media/history_view_media.h @@ -141,8 +141,7 @@ public: } virtual void clearStickerLoopPlayed() { } - virtual int checkAnimationCount() { - return 0; + virtual void checkAnimation() { } [[nodiscard]] virtual QSize sizeForGrouping() const { diff --git a/Telegram/SourceFiles/history/view/media/history_view_media_grouped.cpp b/Telegram/SourceFiles/history/view/media/history_view_media_grouped.cpp index 413b89036..9b6778fc7 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_media_grouped.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_media_grouped.cpp @@ -414,21 +414,19 @@ void GroupedMedia::updateNeedBubbleState() { } void GroupedMedia::stopAnimation() { - for (auto &part : _parts) { + for (const auto &part : _parts) { part.content->stopAnimation(); } } -int GroupedMedia::checkAnimationCount() { - auto result = 0; - for (auto &part : _parts) { - result += part.content->checkAnimationCount(); +void GroupedMedia::checkAnimation() { + for (const auto &part : _parts) { + part.content->checkAnimation(); } - return result; } bool GroupedMedia::hasHeavyPart() const { - for (auto &part : _parts) { + for (const auto &part : _parts) { if (part.content->hasHeavyPart()) { return true; } @@ -437,7 +435,7 @@ bool GroupedMedia::hasHeavyPart() const { } void GroupedMedia::unloadHeavyPart() { - for (auto &part : _parts) { + for (const auto &part : _parts) { part.content->unloadHeavyPart(); } } diff --git a/Telegram/SourceFiles/history/view/media/history_view_media_grouped.h b/Telegram/SourceFiles/history/view/media/history_view_media_grouped.h index 769e6ab7c..184278479 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_media_grouped.h +++ b/Telegram/SourceFiles/history/view/media/history_view_media_grouped.h @@ -88,7 +88,7 @@ public: } void stopAnimation() override; - int checkAnimationCount() override; + void checkAnimation() override; bool hasHeavyPart() const override; void unloadHeavyPart() override; diff --git a/Telegram/SourceFiles/history/view/media/history_view_web_page.h b/Telegram/SourceFiles/history/view/media/history_view_web_page.h index c04cf192c..02d955573 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_web_page.h +++ b/Telegram/SourceFiles/history/view/media/history_view_web_page.h @@ -63,8 +63,8 @@ public: void stopAnimation() override { if (_attach) _attach->stopAnimation(); } - int checkAnimationCount() override { - return _attach ? _attach->checkAnimationCount() : 0; + void checkAnimation() override { + if (_attach) _attach->checkAnimation(); } not_null webpage() { From 23f94c61a4a6f51bbb0561bafc09d054a6da85a9 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 4 Jun 2020 17:31:41 +0400 Subject: [PATCH 09/10] Beta version 2.1.9. - Several crash fixes. --- Telegram/Resources/uwp/AppX/AppxManifest.xml | 2 +- Telegram/Resources/winrc/Telegram.rc | 8 ++++---- Telegram/Resources/winrc/Updater.rc | 8 ++++---- Telegram/SourceFiles/core/version.h | 4 ++-- Telegram/build/version | 8 ++++---- changelog.txt | 4 ++++ 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Telegram/Resources/uwp/AppX/AppxManifest.xml b/Telegram/Resources/uwp/AppX/AppxManifest.xml index 2261e12d6..1fee682e8 100644 --- a/Telegram/Resources/uwp/AppX/AppxManifest.xml +++ b/Telegram/Resources/uwp/AppX/AppxManifest.xml @@ -9,7 +9,7 @@ + Version="2.1.9.0" /> Telegram Desktop Telegram FZ-LLC diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc index 31ea6cb6f..260dc4dc4 100644 --- a/Telegram/Resources/winrc/Telegram.rc +++ b/Telegram/Resources/winrc/Telegram.rc @@ -44,8 +44,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,1,8,0 - PRODUCTVERSION 2,1,8,0 + FILEVERSION 2,1,9,0 + PRODUCTVERSION 2,1,9,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -62,10 +62,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram FZ-LLC" VALUE "FileDescription", "Telegram Desktop" - VALUE "FileVersion", "2.1.8.0" + VALUE "FileVersion", "2.1.9.0" VALUE "LegalCopyright", "Copyright (C) 2014-2020" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "2.1.8.0" + VALUE "ProductVersion", "2.1.9.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc index aef821f64..d3d05ef54 100644 --- a/Telegram/Resources/winrc/Updater.rc +++ b/Telegram/Resources/winrc/Updater.rc @@ -35,8 +35,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,1,8,0 - PRODUCTVERSION 2,1,8,0 + FILEVERSION 2,1,9,0 + PRODUCTVERSION 2,1,9,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -53,10 +53,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram FZ-LLC" VALUE "FileDescription", "Telegram Desktop Updater" - VALUE "FileVersion", "2.1.8.0" + VALUE "FileVersion", "2.1.9.0" VALUE "LegalCopyright", "Copyright (C) 2014-2020" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "2.1.8.0" + VALUE "ProductVersion", "2.1.9.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index 8e7cfe44c..e66744ddd 100644 --- a/Telegram/SourceFiles/core/version.h +++ b/Telegram/SourceFiles/core/version.h @@ -22,7 +22,7 @@ constexpr auto AppId = "{53F49750-6209-4FBF-9CA8-7A333C87D1ED}"_cs; constexpr auto AppNameOld = "Telegram Win (Unofficial)"_cs; constexpr auto AppName = "Telegram Desktop"_cs; constexpr auto AppFile = "Telegram"_cs; -constexpr auto AppVersion = 2001008; -constexpr auto AppVersionStr = "2.1.8"; +constexpr auto AppVersion = 2001009; +constexpr auto AppVersionStr = "2.1.9"; constexpr auto AppBetaVersion = true; constexpr auto AppAlphaVersion = TDESKTOP_ALPHA_VERSION; diff --git a/Telegram/build/version b/Telegram/build/version index 49b43a09d..fa1ee7c9e 100644 --- a/Telegram/build/version +++ b/Telegram/build/version @@ -1,7 +1,7 @@ -AppVersion 2001008 +AppVersion 2001009 AppVersionStrMajor 2.1 -AppVersionStrSmall 2.1.8 -AppVersionStr 2.1.8 +AppVersionStrSmall 2.1.9 +AppVersionStr 2.1.9 BetaChannel 1 AlphaVersion 0 -AppVersionOriginal 2.1.8.beta +AppVersionOriginal 2.1.9.beta diff --git a/changelog.txt b/changelog.txt index d24caa27b..1e73796bb 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +2.1.9 beta (04.06.20) + +- Several crash fixes. + 2.1.8 beta (03.06.20) - Add support for full group message history export. From d0994019cac5265e9f74b259b6903698031b8dfc Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 4 Jun 2020 18:17:47 +0400 Subject: [PATCH 10/10] Beta version 2.1.9: Fix 'edited' field export. Export 'edited' only if the message was edited. --- Telegram/SourceFiles/export/output/export_output_json.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/export/output/export_output_json.cpp b/Telegram/SourceFiles/export/output/export_output_json.cpp index 1ed2d9c01..b106b9806 100644 --- a/Telegram/SourceFiles/export/output/export_output_json.cpp +++ b/Telegram/SourceFiles/export/output/export_output_json.cpp @@ -257,9 +257,7 @@ QByteArray SerializeMessage( SerializeString(message.action.content ? "service" : "message") }, { "date", SerializeDate(message.date) }, - { "edited", SerializeDate(message.edited) }, }; - context.nesting.push_back(Context::kObject); const auto serialized = [&] { context.nesting.pop_back(); @@ -273,6 +271,10 @@ QByteArray SerializeMessage( values.emplace_back(key, value); } }; + if (message.edited) { + pushBare("edited", SerializeDate(message.edited)); + } + const auto push = [&](const QByteArray &key, const auto &value) { if constexpr (std::is_arithmetic_v>) { pushBare(key, Data::NumberToString(value));