From 1fe562ec13b8844cfbdf7ac0494f467f7fc0d2f7 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 10 Apr 2016 15:41:14 +0400 Subject: [PATCH] Fixed crash when bot removes message inline keyboard while editing. --- Telegram/SourceFiles/history.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index da6728515..8f4a16284 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -6978,18 +6978,39 @@ void HistoryMessage::setText(const QString &text, const EntitiesInText &entities } void HistoryMessage::setReplyMarkup(const MTPReplyMarkup *markup) { - if (!markup && !(_flags & MTPDmessage::Flag::f_reply_markup)) return; + if (!markup) { + if (_flags & MTPDmessage::Flag::f_reply_markup) { + _flags &= ~MTPDmessage::Flag::f_reply_markup; + if (Has()) { + RemoveComponents(HistoryMessageReplyMarkup::Bit()); + } + setPendingInitDimensions(); + Notify::replyMarkupUpdated(this); + } + return; + } // optimization: don't create markup component for the case // MTPDreplyKeyboardHide with flags = 0, assume it has f_zero flag if (markup->type() == mtpc_replyKeyboardHide && markup->c_replyKeyboardHide().vflags.v == 0) { + bool changed = false; if (Has()) { RemoveComponents(HistoryMessageReplyMarkup::Bit()); + changed = true; + } + if (!(_flags & MTPDmessage::Flag::f_reply_markup)) { + _flags |= MTPDmessage::Flag::f_reply_markup; + changed = true; + } + if (changed) { setPendingInitDimensions(); Notify::replyMarkupUpdated(this); } } else { + if (!(_flags & MTPDmessage::Flag::f_reply_markup)) { + _flags |= MTPDmessage::Flag::f_reply_markup; + } if (!Has()) { AddComponents(HistoryMessageReplyMarkup::Bit()); }