From e38d6839793ee41e357495e233d27ec3b5c4e49f Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 23 Mar 2017 15:15:21 +0300 Subject: [PATCH] Fix crash in SelfDestructionBox. base::lambda_guarded may destroy the lambda after the owner. In case of SelfDestructionBox it lead to a dtor of a dangling object_ptr. MTP::Sender destroys the lambda handlers together with itself. --- Telegram/SourceFiles/boxes/self_destruction_box.cpp | 4 ++-- Telegram/SourceFiles/boxes/self_destruction_box.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/boxes/self_destruction_box.cpp b/Telegram/SourceFiles/boxes/self_destruction_box.cpp index c35c05885599e..3e5daf8623315 100644 --- a/Telegram/SourceFiles/boxes/self_destruction_box.cpp +++ b/Telegram/SourceFiles/boxes/self_destruction_box.cpp @@ -44,7 +44,7 @@ void SelfDestructionBox::prepare() { addButton(lang(lng_cancel), [this] { closeBox(); }); - MTP::send(MTPaccount_GetAccountTTL(), rpcDone(base::lambda_guarded(this, [this, loading = std::move(loading)](const MTPAccountDaysTTL &result) mutable { + request(MTPaccount_GetAccountTTL()).done([this, loading = std::move(loading)](const MTPAccountDaysTTL &result) mutable { Expects(result.type() == mtpc_accountDaysTTL); Expects(!_ttlValues.empty()); @@ -77,5 +77,5 @@ void SelfDestructionBox::prepare() { closeBox(); }); addButton(lang(lng_cancel), [this] { closeBox(); }); - }))); + }).send(); } diff --git a/Telegram/SourceFiles/boxes/self_destruction_box.h b/Telegram/SourceFiles/boxes/self_destruction_box.h index 27eb2d9d02df0..acbaa011c7fbb 100644 --- a/Telegram/SourceFiles/boxes/self_destruction_box.h +++ b/Telegram/SourceFiles/boxes/self_destruction_box.h @@ -21,6 +21,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #pragma once #include "boxes/abstractbox.h" +#include "mtproto/sender.h" namespace Ui { class RadiobuttonGroup; @@ -28,7 +29,7 @@ class Radiobutton; class FlatLabel; } // namespace Ui -class SelfDestructionBox : public BoxContent { +class SelfDestructionBox : public BoxContent, private MTP::Sender { Q_OBJECT public: