From 67572b0d9ace603179227d5cb20b2a32de8f86db Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 1 Apr 2019 11:42:23 +0300 Subject: [PATCH] Added canceling upload edit media to Data::Media destructors. - We should stop upload media if message was deleted from other client. --- Telegram/SourceFiles/data/data_media_types.cpp | 7 +++++++ Telegram/SourceFiles/history/history_item.cpp | 3 --- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/data/data_media_types.cpp b/Telegram/SourceFiles/data/data_media_types.cpp index 27a14077f..0f05b969a 100644 --- a/Telegram/SourceFiles/data/data_media_types.cpp +++ b/Telegram/SourceFiles/data/data_media_types.cpp @@ -38,6 +38,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_channel.h" #include "lang/lang_keys.h" #include "layout.h" +#include "storage/file_upload.h" namespace Data { namespace { @@ -262,6 +263,9 @@ MediaPhoto::MediaPhoto( } MediaPhoto::~MediaPhoto() { + if (uploading() && !App::quitting()) { + parent()->history()->session().uploader().cancel(parent()->fullId()); + } parent()->history()->owner().unregisterPhotoItem(_photo, parent()); } @@ -499,6 +503,9 @@ MediaFile::MediaFile( } MediaFile::~MediaFile() { + if (uploading() && !App::quitting()) { + parent()->history()->session().uploader().cancel(parent()->fullId()); + } parent()->history()->owner().unregisterDocumentItem( _document, parent()); diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index db4910468..930bbcbd1 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -767,9 +767,6 @@ void HistoryItem::drawInDialog( HistoryItem::~HistoryItem() { _history->owner().notifyItemRemoved(this); App::historyUnregItem(this); - if (id < 0 && !App::quitting()) { - _history->session().uploader().cancel(fullId()); - } } QDateTime ItemDateTime(not_null item) {