Fixed possible crash on quit application when media preview is opened.

This commit is contained in:
23rd
2026-03-20 08:29:28 +03:00
parent 41aabe486b
commit ee58a97156
@@ -60,8 +60,10 @@ struct PreviewOverlayState {
base::unique_qptr<Ui::AbstractButton> background;
base::unique_qptr<Ui::FlatLabel> label;
Fn<void()> extraHide;
rpl::lifetime shutdownGuard;
void clear() {
shutdownGuard.destroy();
menu.reset();
background.reset();
label.reset();
@@ -108,6 +110,11 @@ template <typename MediaData>
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 };
}