From 72940a25e30e34361c9ad294007a5d707404d856 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 6 Jun 2022 12:20:22 +0400 Subject: [PATCH] Fix possible crash in checkbox. --- ui/widgets/checkbox.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/widgets/checkbox.cpp b/ui/widgets/checkbox.cpp index 6bfe533..00d43f8 100644 --- a/ui/widgets/checkbox.cpp +++ b/ui/widgets/checkbox.cpp @@ -707,6 +707,7 @@ void Checkbox::mouseMoveEvent(QMouseEvent *e) { } void Checkbox::mouseReleaseEvent(QMouseEvent *e) { + const auto weak = Ui::MakeWeak(this); if (auto activated = _activatingHandler = ClickHandler::unpressed()) { const auto button = e->button(); crl::on_main(this, [=] { @@ -715,7 +716,9 @@ void Checkbox::mouseReleaseEvent(QMouseEvent *e) { }); } RippleButton::mouseReleaseEvent(e); - _activatingHandler = nullptr; + if (weak) { + _activatingHandler = nullptr; + } } void Checkbox::leaveEventHook(QEvent *e) {