Fix crash in bot callback sending.

This commit is contained in:
John Preston 2020-07-17 08:13:53 +04:00
parent 9463bbd266
commit 04f95e905e

View file

@ -35,10 +35,11 @@ void SendBotCallbackData(
const auto owner = &history->owner(); const auto owner = &history->owner();
const auto api = &session->api(); const auto api = &session->api();
const auto bot = item->getMessageBot(); const auto bot = item->getMessageBot();
const auto fullId = item->fullId();
const auto getButton = [=] { const auto getButton = [=] {
return HistoryMessageMarkupButton::Get( return HistoryMessageMarkupButton::Get(
owner, owner,
item->fullId(), fullId,
row, row,
column); column);
}; };
@ -63,7 +64,11 @@ void SendBotCallbackData(
history->peer->input, history->peer->input,
MTP_int(item->id), MTP_int(item->id),
MTP_bytes(sendData) MTP_bytes(sendData)
)).done([=](const MTPmessages_BotCallbackAnswer &result, auto id) { )).done([=](const MTPmessages_BotCallbackAnswer &result) {
const auto item = owner->message(fullId);
if (!item) {
return;
}
if (const auto button = getButton()) { if (const auto button = getButton()) {
button->requestId = 0; button->requestId = 0;
owner->requestItemRepaint(item); owner->requestItemRepaint(item);
@ -91,7 +96,11 @@ void SendBotCallbackData(
Api::SendProgressType::PlayGame); Api::SendProgressType::PlayGame);
} }
}); });
}).fail([=](const RPCError &error, auto id) { }).fail([=](const RPCError &error) {
const auto item = owner->message(fullId);
if (!item) {
return;
}
// Show error? // Show error?
if (const auto button = getButton()) { if (const auto button = getButton()) {
button->requestId = 0; button->requestId = 0;