diff --git a/Telegram/SourceFiles/data/data_cloud_file.cpp b/Telegram/SourceFiles/data/data_cloud_file.cpp index 258b71d50..6fe8accbb 100644 --- a/Telegram/SourceFiles/data/data_cloud_file.cpp +++ b/Telegram/SourceFiles/data/data_cloud_file.cpp @@ -16,6 +16,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Data { +CloudFile::~CloudFile() { + // Destroy loader with still alive CloudFile with already zero '.loader'. + // Otherwise in ~FileLoader it tries to clear file.loader and crashes. + base::take(loader); +} + void CloudImageView::set( not_null session, QImage image) { @@ -224,7 +230,8 @@ void LoadCloudFile( } // NB! file.loader may be in ~FileLoader() already. if (const auto loader = base::take(file.loader)) { - if (file.flags & CloudFile::Flag::Cancelled) { + if ((file.flags & CloudFile::Flag::Cancelled) + && !loader->cancelled()) { loader->cancel(); } } diff --git a/Telegram/SourceFiles/data/data_cloud_file.h b/Telegram/SourceFiles/data/data_cloud_file.h index e295cd9cc..60fdf72b1 100644 --- a/Telegram/SourceFiles/data/data_cloud_file.h +++ b/Telegram/SourceFiles/data/data_cloud_file.h @@ -34,6 +34,8 @@ struct CloudFile final { }; friend inline constexpr bool is_flag_type(Flag) { return true; }; + ~CloudFile(); + ImageLocation location; std::unique_ptr loader; int byteSize = 0; diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 6451ae507..30d223bef 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 6451ae50741a13b6b8e48835da654e24f34695aa +Subproject commit 30d223befe328ff697b3af879ef69c514d21c5f3