Fix crash on quit from passcode with a box.

This commit is contained in:
John Preston 2019-09-09 18:54:38 +03:00
parent 423254f7eb
commit f90fdce422
3 changed files with 17 additions and 9 deletions

View File

@ -172,7 +172,7 @@ QPixmap MainWindow::grabInner() {
void MainWindow::setupPasscodeLock() { void MainWindow::setupPasscodeLock() {
auto animated = (_main || _intro); auto animated = (_main || _intro);
auto bg = animated ? grabInner() : QPixmap(); auto bg = animated ? grabInner() : QPixmap();
_passcodeLock.create(bodyWidget()); _passcodeLock.create(bodyWidget(), &controller());
updateControlsGeometry(); updateControlsGeometry();
Core::App().hideMediaView(); Core::App().hideMediaView();

View File

@ -19,18 +19,21 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/wrap/vertical_layout.h" #include "ui/wrap/vertical_layout.h"
#include "ui/toast/toast.h" #include "ui/toast/toast.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
#include "window/window_controller.h"
#include "window/window_slide_animation.h" #include "window/window_slide_animation.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "main/main_session.h" #include "main/main_session.h"
namespace Window { namespace Window {
LockWidget::LockWidget(QWidget *parent) : RpWidget(parent) { LockWidget::LockWidget(QWidget *parent, not_null<Controller*> window)
: RpWidget(parent)
, _window(window) {
show(); show();
} }
void LockWidget::setInnerFocus() { void LockWidget::setInnerFocus() {
if (const auto controller = App::wnd()->sessionController()) { if (const auto controller = _window->sessionController()) {
controller->dialogsListFocused().set(false, true); controller->dialogsListFocused().set(false, true);
} }
setFocus(); setFocus();
@ -60,7 +63,7 @@ void LockWidget::animationCallback() {
update(); update();
if (!_a_show.animating()) { if (!_a_show.animating()) {
showChildren(); showChildren();
if (App::wnd()) App::wnd()->setInnerFocus(); _window->widget()->setInnerFocus();
Ui::showChatsList(); Ui::showChatsList();
@ -94,8 +97,10 @@ void LockWidget::paintContent(Painter &p) {
p.fillRect(rect(), st::windowBg); p.fillRect(rect(), st::windowBg);
} }
PasscodeLockWidget::PasscodeLockWidget(QWidget *parent) PasscodeLockWidget::PasscodeLockWidget(
: LockWidget(parent) QWidget *parent,
not_null<Controller*> window)
: LockWidget(parent, window)
, _passcode(this, st::passcodeInput, tr::lng_passcode_ph()) , _passcode(this, st::passcodeInput, tr::lng_passcode_ph())
, _submit(this, tr::lng_passcode_submit(), st::passcodeSubmit) , _submit(this, tr::lng_passcode_submit(), st::passcodeSubmit)
, _logout(this, tr::lng_passcode_logout(tr::now)) { , _logout(this, tr::lng_passcode_logout(tr::now)) {
@ -103,7 +108,7 @@ PasscodeLockWidget::PasscodeLockWidget(QWidget *parent)
connect(_passcode, &Ui::MaskedInputField::submitted, [=] { submit(); }); connect(_passcode, &Ui::MaskedInputField::submitted, [=] { submit(); });
_submit->setClickedCallback([=] { submit(); }); _submit->setClickedCallback([=] { submit(); });
_logout->setClickedCallback([] { App::wnd()->onLogout(); }); _logout->setClickedCallback([=] { window->widget()->onLogout(); });
} }
void PasscodeLockWidget::paintContent(Painter &p) { void PasscodeLockWidget::paintContent(Painter &p) {

View File

@ -21,9 +21,11 @@ class CheckView;
namespace Window { namespace Window {
class Controller;
class LockWidget : public Ui::RpWidget { class LockWidget : public Ui::RpWidget {
public: public:
LockWidget(QWidget *parent); LockWidget(QWidget *parent, not_null<Controller*> window);
virtual void setInnerFocus(); virtual void setInnerFocus();
@ -36,6 +38,7 @@ protected:
private: private:
void animationCallback(); void animationCallback();
const not_null<Controller*> _window;
Ui::Animations::Simple _a_show; Ui::Animations::Simple _a_show;
bool _showBack = false; bool _showBack = false;
QPixmap _cacheUnder, _cacheOver; QPixmap _cacheUnder, _cacheOver;
@ -44,7 +47,7 @@ private:
class PasscodeLockWidget : public LockWidget { class PasscodeLockWidget : public LockWidget {
public: public:
PasscodeLockWidget(QWidget *parent); PasscodeLockWidget(QWidget *parent, not_null<Controller*> window);
void setInnerFocus() override; void setInnerFocus() override;