From bf945e05be9a9f696bdd866cc3427ac1bc7a4825 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 23 Oct 2020 12:54:08 +0300 Subject: [PATCH] Remove promise from map before setting it. GitOrigin-RevId: d721cab5311096631748e632cf8756edaef9d7e1 --- td/telegram/MessagesManager.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index b926ea0fe041..9f1d7c6ed1b2 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -23161,11 +23161,14 @@ void MessagesManager::on_yet_unsent_media_queue_updated(DialogId dialog_id) { } auto m = get_message({dialog_id, MessageId(first_it->first)}); + auto promise = std::move(first_it->second); + queue.erase(first_it); if (m != nullptr) { LOG(INFO) << "Can send " << FullMessageId{dialog_id, m->message_id}; - first_it->second.set_value(std::move(m)); + promise.set_value(std::move(m)); + } else { + promise.set_error(Status::Error(400, "Message not found")); } - queue.erase(first_it); } LOG(INFO) << "Queue for " << dialog_id << " now has size " << queue.size(); if (queue.empty()) {