Skip to content

Commit

Permalink
Fix crash in SelfDestructionBox.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
john-preston committed Mar 23, 2017
1 parent e9ec09b commit e38d683
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Telegram/SourceFiles/boxes/self_destruction_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down Expand Up @@ -77,5 +77,5 @@ void SelfDestructionBox::prepare() {
closeBox();
});
addButton(lang(lng_cancel), [this] { closeBox(); });
})));
}).send();
}
3 changes: 2 additions & 1 deletion Telegram/SourceFiles/boxes/self_destruction_box.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#pragma once

#include "boxes/abstractbox.h"
#include "mtproto/sender.h"

namespace Ui {
class RadiobuttonGroup;
class Radiobutton;
class FlatLabel;
} // namespace Ui

class SelfDestructionBox : public BoxContent {
class SelfDestructionBox : public BoxContent, private MTP::Sender {
Q_OBJECT

public:
Expand Down

0 comments on commit e38d683

Please sign in to comment.