From a87fb9160c9041cfe4515c0cbf3b500ed345e530 Mon Sep 17 00:00:00 2001 From: AlexeyZavar Date: Tue, 2 Apr 2024 02:53:39 +0300 Subject: [PATCH] fix: message shot crashes --- .../ayu/features/messageshot/message_shot.cpp | 39 ++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/ayu/features/messageshot/message_shot.cpp b/Telegram/SourceFiles/ayu/features/messageshot/message_shot.cpp index 1ea11aa04..5e2240da4 100644 --- a/Telegram/SourceFiles/ayu/features/messageshot/message_shot.cpp +++ b/Telegram/SourceFiles/ayu/features/messageshot/message_shot.cpp @@ -16,6 +16,7 @@ #include "data/data_forum.h" #include "data/data_peer.h" #include "data/data_session.h" +#include "dialogs/ui/dialogs_video_userpic.h" #include "history/history.h" #include "history/history_inner_widget.h" #include "history/history_item.h" @@ -359,6 +360,9 @@ QImage Make(not_null box, const ShotConfig &config) { const auto viewport = QRect(0, 0, width, height); + base::flat_map, Ui::PeerUserpicView> userpics; + base::flat_map hiddenSenderUserpics; + Painter p(&image); // draw the messages @@ -385,11 +389,36 @@ QImage Make(not_null box, const ShotConfig &config) { const auto picX = st::msgMargin.left(); const auto picY = y + view->height() - st::msgPhotoSize; - auto userpicView = - message->displayFrom()->hasUserpic() - ? message->displayFrom()->activeUserpicView() - : message->displayFrom()->createUserpicView(); - message->displayFrom()->paintUserpic(p, userpicView, picX, picY, st::msgPhotoSize); + if (const auto from = message->displayFrom()) { + Dialogs::Ui::PaintUserpic( + p, + from, + nullptr, + userpics[from], + picX, + picY, + width, + st::msgPhotoSize, + context.paused); + } else if (const auto info = message->displayHiddenSenderInfo()) { + if (info->customUserpic.empty()) { + info->emptyUserpic.paintCircle( + p, + picX, + picY, + width, + st::msgPhotoSize); + } else { + auto &userpic = hiddenSenderUserpics[message->id]; + const auto valid = info->paintCustomUserpic( + p, + userpic, + picX, + picY, + width, + st::msgPhotoSize); + } + } } y += view->height();