diff --git a/Telegram/SourceFiles/storage/file_download.cpp b/Telegram/SourceFiles/storage/file_download.cpp index 9f49cc8c8..ae7993da4 100644 --- a/Telegram/SourceFiles/storage/file_download.cpp +++ b/Telegram/SourceFiles/storage/file_download.cpp @@ -69,6 +69,13 @@ int Downloader::chooseDcIndexForRequest(MTP::DcId dcId) const { return result; } +Downloader::~Downloader() { + // The file loaders have pointer to downloader and they cancel + // requests in destructor where they use that pointer, so all + // of them need to be destroyed before any internal state of Downloader. + _delayedDestroyedLoaders.clear(); +} + } // namespace Storage namespace { diff --git a/Telegram/SourceFiles/storage/file_download.h b/Telegram/SourceFiles/storage/file_download.h index 5bc1a314f..62631d65a 100644 --- a/Telegram/SourceFiles/storage/file_download.h +++ b/Telegram/SourceFiles/storage/file_download.h @@ -43,6 +43,8 @@ public: void requestedAmountIncrement(MTP::DcId dcId, int index, int amount); int chooseDcIndexForRequest(MTP::DcId dcId) const; + ~Downloader(); + private: base::Observable _taskFinishedObservable; int _priority = 1;