Fix crash in ConnectionType box init.

This commit is contained in:
John Preston 2023-03-12 21:11:22 +04:00
parent 2eaa66e873
commit ce5084c444
2 changed files with 6 additions and 5 deletions

View file

@ -1265,7 +1265,7 @@ object_ptr<Ui::BoxContent> ProxiesBoxController::CreateOwningBox(
object_ptr<Ui::BoxContent> ProxiesBoxController::create() { object_ptr<Ui::BoxContent> ProxiesBoxController::create() {
auto result = Box<ProxiesBox>(this, _settings); auto result = Box<ProxiesBox>(this, _settings);
_toastParent = Ui::BoxShow(result.data()).toastParent(); _show = std::make_shared<Ui::BoxShow>(result.data());
for (const auto &item : _list) { for (const auto &item : _list) {
updateView(item); updateView(item);
} }
@ -1548,9 +1548,9 @@ void ProxiesBoxController::share(const ProxyData &proxy) {
+ ((proxy.type == Type::Mtproto && !proxy.password.isEmpty()) + ((proxy.type == Type::Mtproto && !proxy.password.isEmpty())
? "&secret=" + proxy.password : ""); ? "&secret=" + proxy.password : "");
QGuiApplication::clipboard()->setText(link); QGuiApplication::clipboard()->setText(link);
if (_toastParent) { Ui::Toast::Show(
Ui::Toast::Show(_toastParent, tr::lng_username_copied(tr::now)); _show->toastParent(),
} tr::lng_username_copied(tr::now));
} }
ProxiesBoxController::~ProxiesBoxController() { ProxiesBoxController::~ProxiesBoxController() {

View file

@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mtproto/mtproto_proxy_data.h" #include "mtproto/mtproto_proxy_data.h"
namespace Ui { namespace Ui {
class Show;
class BoxContent; class BoxContent;
class InputField; class InputField;
class PortInput; class PortInput;
@ -117,7 +118,7 @@ private:
rpl::event_stream<ItemView> _views; rpl::event_stream<ItemView> _views;
base::Timer _saveTimer; base::Timer _saveTimer;
rpl::event_stream<ProxyData::Settings> _proxySettingsChanges; rpl::event_stream<ProxyData::Settings> _proxySettingsChanges;
QPointer<QWidget> _toastParent; std::shared_ptr<Ui::Show> _show;
ProxyData _lastSelectedProxy; ProxyData _lastSelectedProxy;
bool _lastSelectedProxyUsed = false; bool _lastSelectedProxyUsed = false;