Fix crash in forwarding box.

This commit is contained in:
John Preston 2018-11-30 09:45:22 +04:00
parent 776dd8b928
commit 03b0c0cff4
2 changed files with 12 additions and 3 deletions

View File

@ -910,7 +910,12 @@ void ChooseRecipientBoxController::prepareViewHook() {
} }
void ChooseRecipientBoxController::rowClicked(not_null<PeerListRow*> row) { void ChooseRecipientBoxController::rowClicked(not_null<PeerListRow*> row) {
_callback(row->peer()); auto weak = base::make_weak(this);
auto callback = std::move(_callback);
callback(row->peer());
if (weak) {
_callback = std::move(callback);
}
} }
auto ChooseRecipientBoxController::createRow( auto ChooseRecipientBoxController::createRow(

View File

@ -198,7 +198,9 @@ private:
}; };
class AddBotToGroupBoxController : public ChatsListBoxController, public base::has_weak_ptr { class AddBotToGroupBoxController
: public ChatsListBoxController
, public base::has_weak_ptr {
public: public:
static void Start(not_null<UserData*> bot); static void Start(not_null<UserData*> bot);
@ -227,7 +229,9 @@ private:
}; };
class ChooseRecipientBoxController : public ChatsListBoxController { class ChooseRecipientBoxController
: public ChatsListBoxController
, public base::has_weak_ptr {
public: public:
ChooseRecipientBoxController( ChooseRecipientBoxController(
FnMut<void(not_null<PeerData*>)> callback); FnMut<void(not_null<PeerData*>)> callback);