From f90fdce4222d19bf54eff1f12fe126f482b8002c Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 9 Sep 2019 18:54:38 +0300 Subject: [PATCH] Fix crash on quit from passcode with a box. --- Telegram/SourceFiles/mainwindow.cpp | 2 +- .../SourceFiles/window/window_lock_widgets.cpp | 17 +++++++++++------ .../SourceFiles/window/window_lock_widgets.h | 7 +++++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index b4d8f68bf..a372f7986 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -172,7 +172,7 @@ QPixmap MainWindow::grabInner() { void MainWindow::setupPasscodeLock() { auto animated = (_main || _intro); auto bg = animated ? grabInner() : QPixmap(); - _passcodeLock.create(bodyWidget()); + _passcodeLock.create(bodyWidget(), &controller()); updateControlsGeometry(); Core::App().hideMediaView(); diff --git a/Telegram/SourceFiles/window/window_lock_widgets.cpp b/Telegram/SourceFiles/window/window_lock_widgets.cpp index 2ebc88176..11770c594 100644 --- a/Telegram/SourceFiles/window/window_lock_widgets.cpp +++ b/Telegram/SourceFiles/window/window_lock_widgets.cpp @@ -19,18 +19,21 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/wrap/vertical_layout.h" #include "ui/toast/toast.h" #include "styles/style_boxes.h" +#include "window/window_controller.h" #include "window/window_slide_animation.h" #include "window/window_session_controller.h" #include "main/main_session.h" namespace Window { -LockWidget::LockWidget(QWidget *parent) : RpWidget(parent) { +LockWidget::LockWidget(QWidget *parent, not_null window) +: RpWidget(parent) +, _window(window) { show(); } void LockWidget::setInnerFocus() { - if (const auto controller = App::wnd()->sessionController()) { + if (const auto controller = _window->sessionController()) { controller->dialogsListFocused().set(false, true); } setFocus(); @@ -60,7 +63,7 @@ void LockWidget::animationCallback() { update(); if (!_a_show.animating()) { showChildren(); - if (App::wnd()) App::wnd()->setInnerFocus(); + _window->widget()->setInnerFocus(); Ui::showChatsList(); @@ -94,8 +97,10 @@ void LockWidget::paintContent(Painter &p) { p.fillRect(rect(), st::windowBg); } -PasscodeLockWidget::PasscodeLockWidget(QWidget *parent) -: LockWidget(parent) +PasscodeLockWidget::PasscodeLockWidget( + QWidget *parent, + not_null window) +: LockWidget(parent, window) , _passcode(this, st::passcodeInput, tr::lng_passcode_ph()) , _submit(this, tr::lng_passcode_submit(), st::passcodeSubmit) , _logout(this, tr::lng_passcode_logout(tr::now)) { @@ -103,7 +108,7 @@ PasscodeLockWidget::PasscodeLockWidget(QWidget *parent) connect(_passcode, &Ui::MaskedInputField::submitted, [=] { submit(); }); _submit->setClickedCallback([=] { submit(); }); - _logout->setClickedCallback([] { App::wnd()->onLogout(); }); + _logout->setClickedCallback([=] { window->widget()->onLogout(); }); } void PasscodeLockWidget::paintContent(Painter &p) { diff --git a/Telegram/SourceFiles/window/window_lock_widgets.h b/Telegram/SourceFiles/window/window_lock_widgets.h index 5e922f619..f2aeb6b3b 100644 --- a/Telegram/SourceFiles/window/window_lock_widgets.h +++ b/Telegram/SourceFiles/window/window_lock_widgets.h @@ -21,9 +21,11 @@ class CheckView; namespace Window { +class Controller; + class LockWidget : public Ui::RpWidget { public: - LockWidget(QWidget *parent); + LockWidget(QWidget *parent, not_null window); virtual void setInnerFocus(); @@ -36,6 +38,7 @@ protected: private: void animationCallback(); + const not_null _window; Ui::Animations::Simple _a_show; bool _showBack = false; QPixmap _cacheUnder, _cacheOver; @@ -44,7 +47,7 @@ private: class PasscodeLockWidget : public LockWidget { public: - PasscodeLockWidget(QWidget *parent); + PasscodeLockWidget(QWidget *parent, not_null window); void setInnerFocus() override;