From a167a8587bc09c9f76b6ec5557f9d9103bb742c7 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 12 Dec 2018 09:47:24 +0400 Subject: [PATCH] Fix crash in main menu right button click. Fixes #5462. --- Telegram/SourceFiles/window/layer_widget.cpp | 27 ++++++++++++-------- Telegram/SourceFiles/window/layer_widget.h | 1 + 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Telegram/SourceFiles/window/layer_widget.cpp b/Telegram/SourceFiles/window/layer_widget.cpp index 7d918fe62..d817aba34 100644 --- a/Telegram/SourceFiles/window/layer_widget.cpp +++ b/Telegram/SourceFiles/window/layer_widget.cpp @@ -375,18 +375,23 @@ void LayerStackWidget::keyPressEvent(QKeyEvent *e) { } void LayerStackWidget::mousePressEvent(QMouseEvent *e) { - if (_hideByBackgroundClick) { - if (const auto layer = currentLayer()) { - if (!layer->closeByOutsideClick()) { - return; - } - } else if (const auto special = _specialLayer.data()) { - if (!special->closeByOutsideClick()) { - return; - } - } - hideCurrent(anim::type::normal); + crl::on_main(this, [=] { backgroundClicked(); }); +} + +void LayerStackWidget::backgroundClicked() { + if (!_hideByBackgroundClick) { + return; } + if (const auto layer = currentLayer()) { + if (!layer->closeByOutsideClick()) { + return; + } + } else if (const auto special = _specialLayer.data()) { + if (!special->closeByOutsideClick()) { + return; + } + } + hideCurrent(anim::type::normal); } void LayerStackWidget::hideCurrent(anim::type animated) { diff --git a/Telegram/SourceFiles/window/layer_widget.h b/Telegram/SourceFiles/window/layer_widget.h index d75c68661..d55644427 100644 --- a/Telegram/SourceFiles/window/layer_widget.h +++ b/Telegram/SourceFiles/window/layer_widget.h @@ -134,6 +134,7 @@ private: void replaceBox( object_ptr box, anim::type animated); + void backgroundClicked(); LayerWidget *pushBox( object_ptr box,