Fix crash in file downloader destruction.

Regression was introduced in 835b1801bc.

We need to destroy all FileLoader instances before destroying the
Downloader instance, because they hold pointers to it and call its
methods in destructor if they need to cancel some MTP requests.
This commit is contained in:
John Preston 2017-04-15 20:35:13 +03:00
parent c10dee11e8
commit 8a8e101cd0
2 changed files with 9 additions and 0 deletions

View File

@ -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 {

View File

@ -43,6 +43,8 @@ public:
void requestedAmountIncrement(MTP::DcId dcId, int index, int amount);
int chooseDcIndexForRequest(MTP::DcId dcId) const;
~Downloader();
private:
base::Observable<void> _taskFinishedObservable;
int _priority = 1;