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,22 +393,32 @@ 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());
// See above. if (const QPixmap* pm = m_memcard_pixmap_cache.Lookup(entry->serial))
if (entry && !entry->serial.empty() && (entry->IsDisc() || entry->IsDiscSet()))
{ {
const std::string icon_path = GameList::GetGameIconPath(entry->serial, entry->path); // If we already have the icon cached, return it.
if (!icon_path.empty()) ret = QIcon(*pm);
return ret;
}
else
{
// See above.
if (entry && !entry->serial.empty() && (entry->IsDisc() || entry->IsDiscSet()))
{ {
QPixmap newpm; const std::string icon_path = GameList::GetGameIconPath(entry->serial, entry->path);
if (!icon_path.empty() && newpm.load(QString::fromStdString(icon_path))) if (!icon_path.empty())
{ {
fixIconPixmapSize(newpm); QPixmap newpm;
ret = QIcon(*m_memcard_pixmap_cache.Insert(entry->serial, std::move(newpm))); if (!icon_path.empty() && newpm.load(QString::fromStdString(icon_path)))
{
fixIconPixmapSize(newpm);
ret = QIcon(*m_memcard_pixmap_cache.Insert(entry->serial, std::move(newpm)));
return ret;
}
} }
} }
} }