From ce5084c44464aec50d8ea3ba2a2b4ba80198fb63 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 12 Mar 2023 21:11:22 +0400 Subject: [PATCH] Fix crash in ConnectionType box init. --- Telegram/SourceFiles/boxes/connection_box.cpp | 8 ++++---- Telegram/SourceFiles/boxes/connection_box.h | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/boxes/connection_box.cpp b/Telegram/SourceFiles/boxes/connection_box.cpp index 8bdece0f3..7c27f59ed 100644 --- a/Telegram/SourceFiles/boxes/connection_box.cpp +++ b/Telegram/SourceFiles/boxes/connection_box.cpp @@ -1265,7 +1265,7 @@ object_ptr ProxiesBoxController::CreateOwningBox( object_ptr ProxiesBoxController::create() { auto result = Box(this, _settings); - _toastParent = Ui::BoxShow(result.data()).toastParent(); + _show = std::make_shared(result.data()); for (const auto &item : _list) { updateView(item); } @@ -1548,9 +1548,9 @@ void ProxiesBoxController::share(const ProxyData &proxy) { + ((proxy.type == Type::Mtproto && !proxy.password.isEmpty()) ? "&secret=" + proxy.password : ""); QGuiApplication::clipboard()->setText(link); - if (_toastParent) { - Ui::Toast::Show(_toastParent, tr::lng_username_copied(tr::now)); - } + Ui::Toast::Show( + _show->toastParent(), + tr::lng_username_copied(tr::now)); } ProxiesBoxController::~ProxiesBoxController() { diff --git a/Telegram/SourceFiles/boxes/connection_box.h b/Telegram/SourceFiles/boxes/connection_box.h index 566a43421..d16d5cd11 100644 --- a/Telegram/SourceFiles/boxes/connection_box.h +++ b/Telegram/SourceFiles/boxes/connection_box.h @@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mtproto/mtproto_proxy_data.h" namespace Ui { +class Show; class BoxContent; class InputField; class PortInput; @@ -117,7 +118,7 @@ private: rpl::event_stream _views; base::Timer _saveTimer; rpl::event_stream _proxySettingsChanges; - QPointer _toastParent; + std::shared_ptr _show; ProxyData _lastSelectedProxy; bool _lastSelectedProxyUsed = false;