mirror of https://github.com/procxx/kepka.git
Fix memory clearing from photos/documents.
This commit is contained in:
parent
9895b45293
commit
e5b2e0a6b5
|
@ -1628,6 +1628,7 @@ namespace {
|
||||||
int64 nowImageCacheSize = imageCacheSize();
|
int64 nowImageCacheSize = imageCacheSize();
|
||||||
if (nowImageCacheSize > serviceImageCacheSize + MemoryForImageCache) {
|
if (nowImageCacheSize > serviceImageCacheSize + MemoryForImageCache) {
|
||||||
App::forgetMedia();
|
App::forgetMedia();
|
||||||
|
Auth().data().forgetMedia();
|
||||||
serviceImageCacheSize = imageCacheSize();
|
serviceImageCacheSize = imageCacheSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1778,6 +1778,7 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re
|
||||||
|
|
||||||
if (_peer) {
|
if (_peer) {
|
||||||
App::forgetMedia();
|
App::forgetMedia();
|
||||||
|
Auth().data().forgetMedia();
|
||||||
_serviceImageCacheSize = imageCacheSize();
|
_serviceImageCacheSize = imageCacheSize();
|
||||||
Auth().downloader().clearPriorities();
|
Auth().downloader().clearPriorities();
|
||||||
|
|
||||||
|
|
|
@ -2880,6 +2880,10 @@ TaskId startImageLoad(const StorageKey &location, mtpFileLoader *loader) {
|
||||||
std::make_unique<ImageLoadTask>(j->first, location, loader));
|
std::make_unique<ImageLoadTask>(j->first, location, loader));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool willImageLoad(const StorageKey &location) {
|
||||||
|
return _imagesMap.constFind(location) != _imagesMap.cend();
|
||||||
|
}
|
||||||
|
|
||||||
int32 hasImages() {
|
int32 hasImages() {
|
||||||
return _imagesMap.size();
|
return _imagesMap.size();
|
||||||
}
|
}
|
||||||
|
@ -3024,6 +3028,10 @@ bool copyAudio(const StorageKey &oldLocation, const StorageKey &newLocation) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool willAudioLoad(const StorageKey &location) {
|
||||||
|
return _audiosMap.constFind(location) != _audiosMap.cend();
|
||||||
|
}
|
||||||
|
|
||||||
int32 hasAudios() {
|
int32 hasAudios() {
|
||||||
return _audiosMap.size();
|
return _audiosMap.size();
|
||||||
}
|
}
|
||||||
|
@ -3130,6 +3138,10 @@ TaskId startWebFileLoad(const QString &url, webFileLoader *loader) {
|
||||||
std::make_unique<WebFileLoadTask>(j->first, url, loader));
|
std::make_unique<WebFileLoadTask>(j->first, url, loader));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool willWebFileLoad(const QString &url) {
|
||||||
|
return _webFilesMap.constFind(url) != _webFilesMap.cend();
|
||||||
|
}
|
||||||
|
|
||||||
int32 hasWebFiles() {
|
int32 hasWebFiles() {
|
||||||
return _webFilesMap.size();
|
return _webFilesMap.size();
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,6 +95,7 @@ FileLocation readFileLocation(MediaKey location, bool check = true);
|
||||||
void writeImage(const StorageKey &location, const ImagePtr &img);
|
void writeImage(const StorageKey &location, const ImagePtr &img);
|
||||||
void writeImage(const StorageKey &location, const StorageImageSaved &jpeg, bool overwrite = true);
|
void writeImage(const StorageKey &location, const StorageImageSaved &jpeg, bool overwrite = true);
|
||||||
TaskId startImageLoad(const StorageKey &location, mtpFileLoader *loader);
|
TaskId startImageLoad(const StorageKey &location, mtpFileLoader *loader);
|
||||||
|
bool willImageLoad(const StorageKey &location);
|
||||||
int32 hasImages();
|
int32 hasImages();
|
||||||
qint64 storageImagesSize();
|
qint64 storageImagesSize();
|
||||||
|
|
||||||
|
@ -107,12 +108,14 @@ qint64 storageStickersSize();
|
||||||
|
|
||||||
void writeAudio(const StorageKey &location, const QByteArray &data, bool overwrite = true);
|
void writeAudio(const StorageKey &location, const QByteArray &data, bool overwrite = true);
|
||||||
TaskId startAudioLoad(const StorageKey &location, mtpFileLoader *loader);
|
TaskId startAudioLoad(const StorageKey &location, mtpFileLoader *loader);
|
||||||
|
bool willAudioLoad(const StorageKey &location);
|
||||||
bool copyAudio(const StorageKey &oldLocation, const StorageKey &newLocation);
|
bool copyAudio(const StorageKey &oldLocation, const StorageKey &newLocation);
|
||||||
int32 hasAudios();
|
int32 hasAudios();
|
||||||
qint64 storageAudiosSize();
|
qint64 storageAudiosSize();
|
||||||
|
|
||||||
void writeWebFile(const QString &url, const QByteArray &data, bool overwrite = true);
|
void writeWebFile(const QString &url, const QByteArray &data, bool overwrite = true);
|
||||||
TaskId startWebFileLoad(const QString &url, webFileLoader *loader);
|
TaskId startWebFileLoad(const QString &url, webFileLoader *loader);
|
||||||
|
bool willWebFileLoad(const QString &url);
|
||||||
int32 hasWebFiles();
|
int32 hasWebFiles();
|
||||||
qint64 storageWebFilesSize();
|
qint64 storageWebFilesSize();
|
||||||
|
|
||||||
|
|
|
@ -797,7 +797,9 @@ void Image::forget() const {
|
||||||
if (_data.isNull()) return;
|
if (_data.isNull()) return;
|
||||||
|
|
||||||
invalidateSizeCache();
|
invalidateSizeCache();
|
||||||
if (_saved.isEmpty()) {
|
/*if (hasLocalCopy()) {
|
||||||
|
_saved.clear();
|
||||||
|
} else */if (_saved.isEmpty()) {
|
||||||
QBuffer buffer(&_saved);
|
QBuffer buffer(&_saved);
|
||||||
if (!_data.save(&buffer, _format)) {
|
if (!_data.save(&buffer, _format)) {
|
||||||
if (_data.save(&buffer, "PNG")) {
|
if (_data.save(&buffer, "PNG")) {
|
||||||
|
@ -1030,6 +1032,10 @@ int32 StorageImage::countHeight() const {
|
||||||
return _location.height();
|
return _location.height();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool StorageImage::hasLocalCopy() const {
|
||||||
|
return Local::willImageLoad(storageKey(_location));
|
||||||
|
}
|
||||||
|
|
||||||
void StorageImage::setInformation(int32 size, int32 width, int32 height) {
|
void StorageImage::setInformation(int32 size, int32 width, int32 height) {
|
||||||
_size = size;
|
_size = size;
|
||||||
_location.setSize(width, height);
|
_location.setSize(width, height);
|
||||||
|
@ -1070,6 +1076,10 @@ int WebFileImage::countHeight() const {
|
||||||
return _height;
|
return _height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WebFileImage::hasLocalCopy() const {
|
||||||
|
return Local::willImageLoad(storageKey(_location));
|
||||||
|
}
|
||||||
|
|
||||||
void WebFileImage::setInformation(int size, int width, int height) {
|
void WebFileImage::setInformation(int size, int width, int height) {
|
||||||
_size = size;
|
_size = size;
|
||||||
_width = width;
|
_width = width;
|
||||||
|
@ -1194,6 +1204,10 @@ int32 WebImage::countHeight() const {
|
||||||
return _height;
|
return _height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WebImage::hasLocalCopy() const {
|
||||||
|
return Local::willWebFileLoad(_url);
|
||||||
|
}
|
||||||
|
|
||||||
void WebImage::setInformation(int32 size, int32 width, int32 height) {
|
void WebImage::setInformation(int32 size, int32 width, int32 height) {
|
||||||
_size = size;
|
_size = size;
|
||||||
setSize(width, height);
|
setSize(width, height);
|
||||||
|
|
|
@ -324,6 +324,10 @@ protected:
|
||||||
return _data.height();
|
return _data.height();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool hasLocalCopy() const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
mutable QByteArray _saved, _format;
|
mutable QByteArray _saved, _format;
|
||||||
mutable bool _forgot;
|
mutable bool _forgot;
|
||||||
mutable QPixmap _data;
|
mutable QPixmap _data;
|
||||||
|
@ -413,6 +417,8 @@ protected:
|
||||||
void setInformation(int32 size, int32 width, int32 height) override;
|
void setInformation(int32 size, int32 width, int32 height) override;
|
||||||
FileLoader *createLoader(LoadFromCloudSetting fromCloud, bool autoLoading) override;
|
FileLoader *createLoader(LoadFromCloudSetting fromCloud, bool autoLoading) override;
|
||||||
|
|
||||||
|
bool hasLocalCopy() const override;
|
||||||
|
|
||||||
StorageImageLocation _location;
|
StorageImageLocation _location;
|
||||||
int32 _size;
|
int32 _size;
|
||||||
|
|
||||||
|
@ -434,6 +440,8 @@ protected:
|
||||||
return _box;
|
return _box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasLocalCopy() const override;
|
||||||
|
|
||||||
WebFileLocation _location;
|
WebFileLocation _location;
|
||||||
QSize _box;
|
QSize _box;
|
||||||
int _width = 0;
|
int _width = 0;
|
||||||
|
@ -496,6 +504,8 @@ protected:
|
||||||
int32 countWidth() const override;
|
int32 countWidth() const override;
|
||||||
int32 countHeight() const override;
|
int32 countHeight() const override;
|
||||||
|
|
||||||
|
bool hasLocalCopy() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString _url;
|
QString _url;
|
||||||
QSize _box;
|
QSize _box;
|
||||||
|
|
Loading…
Reference in New Issue