Fix crash in destructor of Data::CloudFile.

This commit is contained in:
John Preston
2020-06-03 13:48:11 +04:00
parent 63c6a1db82
commit f88b97553e
3 changed files with 11 additions and 2 deletions
@@ -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<Main::Session*> 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();
}
}