Added canceling upload edit media to Data::Media destructors.

- We should stop upload media if message was deleted from other client.
This commit is contained in:
23rd 2019-04-01 11:42:23 +03:00 committed by John Preston
parent 5554867553
commit 67572b0d9a
2 changed files with 7 additions and 3 deletions

View File

@ -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());

View File

@ -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<const HistoryItem*> item) {