From 11b965e82e35f97e0ccb6b2be923226b2a1763e1 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 4 Feb 2021 19:26:49 +0400 Subject: [PATCH] Skip image context actions for not-loaded photos. --- .../history/admin_log/history_admin_log_inner.cpp | 15 +++++++++------ .../SourceFiles/history/history_inner_widget.cpp | 15 +++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp index 0df987662..069ec5b1a 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp @@ -1088,12 +1088,15 @@ void InnerWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { } if (lnkPhoto) { const auto photo = lnkPhoto->photo(); - _menu->addAction(tr::lng_context_save_image(tr::now), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [=] { - savePhotoToFile(photo); - })); - _menu->addAction(tr::lng_context_copy_image(tr::now), [=] { - copyContextImage(photo); - }); + const auto media = photo->activeMediaView(); + if (!photo->isNull() && media && media->loaded()) { + _menu->addAction(tr::lng_context_save_image(tr::now), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [=] { + savePhotoToFile(photo); + })); + _menu->addAction(tr::lng_context_copy_image(tr::now), [=] { + copyContextImage(photo); + }); + } if (photo->hasAttachedStickers()) { const auto controller = _controller; auto callback = [=] { diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 704d5d95d..495376acc 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -1579,12 +1579,15 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { } }; const auto addPhotoActions = [&](not_null photo) { - _menu->addAction(tr::lng_context_save_image(tr::now), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [=] { - savePhotoToFile(photo); - })); - _menu->addAction(tr::lng_context_copy_image(tr::now), [=] { - copyContextImage(photo); - }); + const auto media = photo->activeMediaView(); + if (!photo->isNull() && media && media->loaded()) { + _menu->addAction(tr::lng_context_save_image(tr::now), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [=] { + savePhotoToFile(photo); + })); + _menu->addAction(tr::lng_context_copy_image(tr::now), [=] { + copyContextImage(photo); + }); + } if (photo->hasAttachedStickers()) { _menu->addAction(tr::lng_context_attached_stickers(tr::now), [=] { session->api().attachedStickers().requestAttachedStickerSets(