mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 14:38:15 +00:00
Don't unload all media on switching between chats.
This commit is contained in:
@@ -42,7 +42,7 @@ int64 ComputeUsage(const QImage &image) {
|
||||
Core::MediaActiveCache<const Image> &ActiveCache() {
|
||||
static auto Instance = Core::MediaActiveCache<const Image>(
|
||||
kMemoryForCache,
|
||||
[](const Image *image) { image->forget(); });
|
||||
[](const Image *image) { image->unload(); });
|
||||
return Instance;
|
||||
}
|
||||
|
||||
@@ -769,9 +769,9 @@ void Image::checkSource() const {
|
||||
ActiveCache().up(this);
|
||||
}
|
||||
|
||||
void Image::forget() const {
|
||||
void Image::unload() const {
|
||||
_source->takeLoaded();
|
||||
_source->forget();
|
||||
_source->unload();
|
||||
invalidateSizeCache();
|
||||
ActiveCache().decrement(ComputeUsage(_data));
|
||||
_data = QImage();
|
||||
@@ -800,6 +800,6 @@ void Image::invalidateSizeCache() const {
|
||||
}
|
||||
|
||||
Image::~Image() {
|
||||
forget();
|
||||
unload();
|
||||
ActiveCache().remove(this);
|
||||
}
|
||||
|
@@ -54,7 +54,7 @@ public:
|
||||
bool loadFirst,
|
||||
bool prior) = 0;
|
||||
virtual QImage takeLoaded() = 0;
|
||||
virtual void forget() = 0;
|
||||
virtual void unload() = 0;
|
||||
|
||||
virtual void automaticLoad(
|
||||
Data::FileOrigin origin,
|
||||
@@ -229,7 +229,7 @@ public:
|
||||
|
||||
bool loaded() const;
|
||||
bool isNull() const;
|
||||
void forget() const;
|
||||
void unload() const;
|
||||
void setDelayedStorageLocation(
|
||||
Data::FileOrigin origin,
|
||||
const StorageImageLocation &location);
|
||||
|
@@ -37,7 +37,7 @@ QImage ImageSource::takeLoaded() {
|
||||
return _data;
|
||||
}
|
||||
|
||||
void ImageSource::forget() {
|
||||
void ImageSource::unload() {
|
||||
}
|
||||
|
||||
void ImageSource::automaticLoad(
|
||||
@@ -161,7 +161,7 @@ QImage LocalFileSource::takeLoaded() {
|
||||
return std::move(_data);
|
||||
}
|
||||
|
||||
void LocalFileSource::forget() {
|
||||
void LocalFileSource::unload() {
|
||||
_data = QImage();
|
||||
}
|
||||
|
||||
@@ -361,10 +361,6 @@ void RemoteSource::loadEvenCancelled(
|
||||
return load(origin, loadFirst, prior);
|
||||
}
|
||||
|
||||
RemoteSource::~RemoteSource() {
|
||||
forget();
|
||||
}
|
||||
|
||||
bool RemoteSource::displayLoading() {
|
||||
return loaderValid()
|
||||
&& (!_loader->loadingLocal() || !_loader->autoLoading());
|
||||
@@ -380,7 +376,7 @@ void RemoteSource::cancel() {
|
||||
std::unique_ptr<FileLoader>(loader));
|
||||
}
|
||||
|
||||
void RemoteSource::forget() {
|
||||
void RemoteSource::unload() {
|
||||
if (loaderValid()) {
|
||||
destroyLoaderDelayed();
|
||||
}
|
||||
@@ -394,6 +390,10 @@ int RemoteSource::loadOffset() {
|
||||
return loaderValid() ? _loader->currentOffset() : 0;
|
||||
}
|
||||
|
||||
RemoteSource::~RemoteSource() {
|
||||
unload();
|
||||
}
|
||||
|
||||
const StorageImageLocation &RemoteSource::location() {
|
||||
return StorageImageLocation::Null;
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ public:
|
||||
bool loadFirst,
|
||||
bool prior) override;
|
||||
QImage takeLoaded() override;
|
||||
void forget() override;
|
||||
void unload() override;
|
||||
|
||||
void automaticLoad(
|
||||
Data::FileOrigin origin,
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
bool loadFirst,
|
||||
bool prior) override;
|
||||
QImage takeLoaded() override;
|
||||
void forget() override;
|
||||
void unload() override;
|
||||
|
||||
void automaticLoad(
|
||||
Data::FileOrigin origin,
|
||||
@@ -126,7 +126,7 @@ public:
|
||||
bool loadFirst,
|
||||
bool prior) override;
|
||||
QImage takeLoaded() override;
|
||||
void forget() override;
|
||||
void unload() override;
|
||||
|
||||
void automaticLoad(
|
||||
Data::FileOrigin origin,
|
||||
|
Reference in New Issue
Block a user