Qt: Check cache when getting game icon for window

Apparently forgot this...
This commit is contained in:
Stenzek 2025-07-10 21:33:24 +10:00
parent 9e319ff495
commit 2308c5ddc6
No known key found for this signature in database

View File

@ -393,11 +393,19 @@ QIcon GameListModel::getIconForGame(const QString& path)
{ {
QIcon ret; QIcon ret;
if (m_show_game_icons) if (m_show_game_icons && !path.isEmpty())
{ {
const auto lock = GameList::GetLock(); const auto lock = GameList::GetLock();
const GameList::Entry* entry = GameList::GetEntryForPath(path.toStdString()); const GameList::Entry* entry = GameList::GetEntryForPath(path.toStdString());
if (const QPixmap* pm = m_memcard_pixmap_cache.Lookup(entry->serial))
{
// If we already have the icon cached, return it.
ret = QIcon(*pm);
return ret;
}
else
{
// See above. // See above.
if (entry && !entry->serial.empty() && (entry->IsDisc() || entry->IsDiscSet())) if (entry && !entry->serial.empty() && (entry->IsDisc() || entry->IsDiscSet()))
{ {
@ -409,6 +417,8 @@ QIcon GameListModel::getIconForGame(const QString& path)
{ {
fixIconPixmapSize(newpm); fixIconPixmapSize(newpm);
ret = QIcon(*m_memcard_pixmap_cache.Insert(entry->serial, std::move(newpm))); ret = QIcon(*m_memcard_pixmap_cache.Insert(entry->serial, std::move(newpm)));
return ret;
}
} }
} }
} }