From f671897a4db0897d74296353f5244e8af2622901 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 24 May 2023 20:18:28 +0400 Subject: [PATCH] Fix a possible crash in Go to Message on macOS. Fixes #26273. This crash happens with a very deep stack trace that is caused by destroying shared media layer on Go to Message click, which starts destroying Media::ListWidget, which destroys Ui::PopupMenu, which is a window, so when it destructs it triggers a sync repaint of the main window (by a system event), which tries to render the new messages slice, which starts a photo download, which calls an item repaint in Data::Session, and the semi-destroyed Media::ListWidget is still subscribed to the item repaint requests and tries to repaint and crashes there. The fix is to destroy all session-related subscriptions before the PopupMenu. --- Telegram/SourceFiles/info/media/info_media_list_widget.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/info/media/info_media_list_widget.h b/Telegram/SourceFiles/info/media/info_media_list_widget.h index e95d5842b..e9149d336 100644 --- a/Telegram/SourceFiles/info/media/info_media_list_widget.h +++ b/Telegram/SourceFiles/info/media/info_media_list_widget.h @@ -295,7 +295,6 @@ private: bool _wasSelectedText = false; // was some text selected in current drag action const std::unique_ptr _dateBadge; - base::flat_map, rpl::lifetime> _trackedSessions; base::unique_qptr _contextMenu; rpl::event_stream<> _checkForHide; @@ -305,6 +304,8 @@ private: QPoint _trippleClickPoint; crl::time _trippleClickStartTime = 0; + base::flat_map, rpl::lifetime> _trackedSessions; + }; } // namespace Media