From ee58a9715672115b08dff8c8d3ef3438c4b46a28 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 20 Mar 2026 08:29:28 +0300 Subject: [PATCH] Fixed possible crash on quit application when media preview is opened. --- .../history/view/history_view_reaction_preview.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Telegram/SourceFiles/history/view/history_view_reaction_preview.cpp b/Telegram/SourceFiles/history/view/history_view_reaction_preview.cpp index 70be64578f..36ccc6bef1 100644 --- a/Telegram/SourceFiles/history/view/history_view_reaction_preview.cpp +++ b/Telegram/SourceFiles/history/view/history_view_reaction_preview.cpp @@ -60,8 +60,10 @@ struct PreviewOverlayState { base::unique_qptr background; base::unique_qptr label; Fn extraHide; + rpl::lifetime shutdownGuard; void clear() { + shutdownGuard.destroy(); menu.reset(); background.reset(); label.reset(); @@ -108,6 +110,11 @@ template clickableRaw->raise(); }, clickableRaw->lifetime()); + // Prevent running state destructor from within a child widget's + // destructor, which would trigger a double-delete through unique_qptr. + mainwidget->death() | rpl::on_next([s = state] { + }, state->shutdownGuard); + return { state, hideAll }; }