From c6aba83a6bd771f04e587e455afbe28d4f475a72 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 1 Nov 2022 17:16:02 +0400 Subject: [PATCH] Fix crash on local edit draft, fix reading drafts. --- Telegram/SourceFiles/history/history_widget.cpp | 3 ++- Telegram/SourceFiles/storage/storage_account.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index ed41c4d3f..198edfa10 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -1954,7 +1954,8 @@ void HistoryWidget::applyDraft(FieldHistoryAction fieldHistoryAction) { requestMessageData(_editMsgId); } } else if (!readyToForward()) { - _processingReplyId = _history->localDraft({})->msgId; + const auto draft = _history->localDraft({}); + _processingReplyId = draft ? draft->msgId : MsgId(); processReply(); } } diff --git a/Telegram/SourceFiles/storage/storage_account.cpp b/Telegram/SourceFiles/storage/storage_account.cpp index 4c845ea21..c2fea1afe 100644 --- a/Telegram/SourceFiles/storage/storage_account.cpp +++ b/Telegram/SourceFiles/storage/storage_account.cpp @@ -1363,8 +1363,8 @@ void Account::readDraftsWithCursors(not_null history) { for (auto i = 0; i != count; ++i) { TextWithTags data; QByteArray tagsSerialized; - qint64 keyValue = 0; - qint32 keyValueOld = 0, messageId = 0, uncheckedPreviewState = 0; + qint64 keyValue = 0, messageId = 0; + qint32 keyValueOld = 0, uncheckedPreviewState = 0; if (keysOld) { draft.stream >> keyValueOld; } else {