Fix clearing of album thumbnails cache.

I hope it fixes #7361.
This commit is contained in:
John Preston 2021-03-12 16:09:58 +04:00
parent 8fee156d21
commit 2509f05e28

View file

@ -285,6 +285,8 @@ void GroupedMedia::draw(
const QRect &clip, const QRect &clip,
TextSelection selection, TextSelection selection,
crl::time ms) const { crl::time ms) const {
auto wasCache = false;
auto nowCache = false;
const auto groupPadding = groupedPadding(); const auto groupPadding = groupedPadding();
const auto fullSelection = (selection == FullSelection); const auto fullSelection = (selection == FullSelection);
const auto textSelection = (_mode == Mode::Column) const auto textSelection = (_mode == Mode::Column)
@ -305,6 +307,9 @@ void GroupedMedia::draw(
const auto highlightOpacity = (_mode == Mode::Grid) const auto highlightOpacity = (_mode == Mode::Grid)
? _parent->highlightOpacity(part.item) ? _parent->highlightOpacity(part.item)
: 0.; : 0.;
if (!part.cache.isNull()) {
wasCache = true;
}
part.content->drawGrouped( part.content->drawGrouped(
p, p,
clip, clip,
@ -316,6 +321,12 @@ void GroupedMedia::draw(
highlightOpacity, highlightOpacity,
&part.cacheKey, &part.cacheKey,
&part.cache); &part.cache);
if (!part.cache.isNull()) {
nowCache = true;
}
}
if (nowCache && !wasCache) {
history()->owner().registerHeavyViewPart(_parent);
} }
// date // date
@ -661,7 +672,7 @@ void GroupedMedia::checkAnimation() {
bool GroupedMedia::hasHeavyPart() const { bool GroupedMedia::hasHeavyPart() const {
for (const auto &part : _parts) { for (const auto &part : _parts) {
if (part.content->hasHeavyPart()) { if (!part.cache.isNull() || part.content->hasHeavyPart()) {
return true; return true;
} }
} }
@ -671,6 +682,8 @@ bool GroupedMedia::hasHeavyPart() const {
void GroupedMedia::unloadHeavyPart() { void GroupedMedia::unloadHeavyPart() {
for (const auto &part : _parts) { for (const auto &part : _parts) {
part.content->unloadHeavyPart(); part.content->unloadHeavyPart();
part.cacheKey = 0;
part.cache = QPixmap();
} }
} }