From 05df4f832b335ca280a2b34180404d5104e6bc9e Mon Sep 17 00:00:00 2001 From: John Preston <johnprestonmail@gmail.com> Date: Fri, 5 Jun 2020 14:00:06 +0400 Subject: [PATCH] Fix crash in theme editor closing. --- .../SourceFiles/window/themes/window_theme_editor.cpp | 8 ++++---- Telegram/SourceFiles/window/themes/window_theme_editor.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor.cpp b/Telegram/SourceFiles/window/themes/window_theme_editor.cpp index 3530ee2ba..efeb5cf09 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_editor.cpp @@ -702,20 +702,20 @@ void Editor::showMenu() { if (_menu) { return; } - _menu.create(this); - _menu->setHiddenCallback([weak = Ui::MakeWeak(this), menu = _menu.data()]{ + _menu = base::make_unique_q<Ui::DropdownMenu>(this); + _menu->setHiddenCallback([weak = Ui::MakeWeak(this), menu = _menu.get()]{ menu->deleteLater(); if (weak && weak->_menu == menu) { weak->_menu = nullptr; weak->_menuToggle->setForceRippled(false); } }); - _menu->setShowStartCallback(crl::guard(this, [this, menu = _menu.data()]{ + _menu->setShowStartCallback(crl::guard(this, [this, menu = _menu.get()]{ if (_menu == menu) { _menuToggle->setForceRippled(true); } })); - _menu->setHideStartCallback(crl::guard(this, [this, menu = _menu.data()]{ + _menu->setHideStartCallback(crl::guard(this, [this, menu = _menu.get()]{ if (_menu == menu) { _menuToggle->setForceRippled(false); } diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor.h b/Telegram/SourceFiles/window/themes/window_theme_editor.h index b8e459888..4daf7473b 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor.h +++ b/Telegram/SourceFiles/window/themes/window_theme_editor.h @@ -80,7 +80,7 @@ private: QPointer<Inner> _inner; object_ptr<Ui::CrossButton> _close; object_ptr<Ui::IconButton> _menuToggle; - object_ptr<Ui::DropdownMenu> _menu = { nullptr }; + base::unique_qptr<Ui::DropdownMenu> _menu; object_ptr<Ui::MultiSelect> _select; object_ptr<Ui::PlainShadow> _leftShadow; object_ptr<Ui::PlainShadow> _topShadow;