Qt: Fix disc icon being used for games without icons

This commit is contained in:
Stenzek 2025-07-20 12:10:38 +10:00
parent df432c6c64
commit 5fd61b6e3a
No known key found for this signature in database

View File

@ -363,20 +363,27 @@ const QPixmap& GameListModel::getIconPixmapForEntry(const GameList::Entry* ge) c
{
QPixmap* item = m_memcard_pixmap_cache.Lookup(ge->serial);
if (item)
return *item;
// Assumes game list lock is held.
const std::string path = GameList::GetGameIconPath(ge->serial, ge->path);
QPixmap pm;
if (!path.empty() && pm.load(QString::fromStdString(path)))
{
fixIconPixmapSize(pm);
return *m_memcard_pixmap_cache.Insert(ge->serial, std::move(pm));
if (!item->isNull())
return *item;
}
else
{
// Assumes game list lock is held.
const std::string path = GameList::GetGameIconPath(ge->serial, ge->path);
QPixmap pm;
if (!path.empty() && pm.load(QString::fromStdString(path)))
{
fixIconPixmapSize(pm);
return *m_memcard_pixmap_cache.Insert(ge->serial, std::move(pm));
}
return *m_memcard_pixmap_cache.Insert(ge->serial, m_type_pixmaps[static_cast<u32>(ge->type)]);
// Stop it trying again in the future.
m_memcard_pixmap_cache.Insert(ge->serial, {});
}
}
// If we don't have a pixmap, we return the type pixmap.
return m_type_pixmaps[static_cast<u32>(ge->type)];
}