Qt: Fix rare bug where covers get stuck in loading state

When quickly changing cover scale.
This commit is contained in:
Stenzek
2025-10-11 12:25:14 +10:00
parent 50a9f04dd9
commit 3552a5b001
2 changed files with 12 additions and 0 deletions

View File

@@ -126,6 +126,13 @@ public:
Evict(m_items.size() - m_max_capacity);
}
template<typename F>
void Apply(const F& func)
{
for (auto& [key, value] : m_items)
func(const_cast<const K&>(key), value.value);
}
private:
void ShrinkForNewItem()
{

View File

@@ -278,6 +278,11 @@ void GameListModel::setCoverScale(float scale)
m_cover_scale = scale;
// Invalidate all pending loads. This stops the case where the user changes the scale,
// then quickly changes back before the loads finish, resulting in the image never loading.
m_cover_pixmap_cache.Apply(
[](const std::string&, CoverPixmapCacheEntry& entry) { entry.scale = entry.is_loading ? 0.0f : entry.scale; });
Host::SetBaseFloatSettingValue("UI", "GameListCoverArtScale", scale);
Host::CommitBaseSettingChanges();
updateCoverScale();