Skip to content

Commit b8952da

Browse files
committed
Qt: Don't use memcard icon cache for window icon when scaled
It'll get scaled up and down again otherwise.
1 parent 3cb275d commit b8952da

File tree

4 files changed

+27
-27
lines changed

4 files changed

+27
-27
lines changed

src/duckstation-qt/gamelistwidget.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -457,36 +457,36 @@ QIcon GameListModel::getIconForGame(const QString& path)
457457
{
458458
QIcon ret;
459459

460-
if (m_show_game_icons && !path.isEmpty())
461-
{
462-
const auto lock = GameList::GetLock();
463-
const GameList::Entry* entry = GameList::GetEntryForPath(path.toStdString());
464-
if (!entry)
465-
return ret;
460+
if (!m_show_game_icons || path.isEmpty())
461+
return ret;
466462

463+
const auto lock = GameList::GetLock();
464+
const GameList::Entry* entry = GameList::GetEntryForPath(path.toStdString());
465+
if (!entry || entry->serial.empty() || !entry->IsDisc() && !entry->IsDiscSet())
466+
return ret;
467+
468+
// Only use the cache if we're not using larger icons. Otherwise they'll get double scaled.
469+
// Provides a small performance boost when using default size icons.
470+
if (m_icon_size == MEMORY_CARD_ICON_SIZE)
471+
{
467472
if (const QPixmap* pm = m_memcard_pixmap_cache.Lookup(entry->serial))
468473
{
469474
// If we already have the icon cached, return it.
470475
ret = QIcon(*pm);
471476
return ret;
472477
}
473-
else
478+
}
479+
480+
// See above.
481+
const std::string icon_path = GameList::GetGameIconPath(entry->serial, entry->path);
482+
if (!icon_path.empty())
483+
{
484+
QPixmap newpm;
485+
if (!icon_path.empty() && newpm.load(QString::fromStdString(icon_path)))
474486
{
475-
// See above.
476-
if (!entry->serial.empty() && (entry->IsDisc() || entry->IsDiscSet()))
477-
{
478-
const std::string icon_path = GameList::GetGameIconPath(entry->serial, entry->path);
479-
if (!icon_path.empty())
480-
{
481-
QPixmap newpm;
482-
if (!icon_path.empty() && newpm.load(QString::fromStdString(icon_path)))
483-
{
484-
fixIconPixmapSize(newpm);
485-
ret = QIcon(*m_memcard_pixmap_cache.Insert(entry->serial, std::move(newpm)));
486-
return ret;
487-
}
488-
}
489-
}
487+
fixIconPixmapSize(newpm);
488+
ret = QIcon(*m_memcard_pixmap_cache.Insert(entry->serial, std::move(newpm)));
489+
return ret;
490490
}
491491
}
492492

src/duckstation-qt/mainwindow.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,12 +641,12 @@ void MainWindow::onSystemDestroyed()
641641
switchToGameListView();
642642
}
643643

644-
void MainWindow::onSystemGameChanged(const QString& filename, const QString& game_serial, const QString& game_title)
644+
void MainWindow::onSystemGameChanged(const QString& path, const QString& game_serial, const QString& game_title)
645645
{
646-
s_current_game_path = filename;
646+
s_current_game_path = path;
647647
s_current_game_title = game_title;
648648
s_current_game_serial = game_serial;
649-
s_current_game_icon = m_game_list_widget->getModel()->getIconForGame(filename);
649+
s_current_game_icon = m_game_list_widget->getModel()->getIconForGame(path);
650650

651651
updateWindowTitle();
652652
}

src/duckstation-qt/mainwindow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ private Q_SLOTS:
153153
void onSystemDestroyed();
154154
void onSystemPaused();
155155
void onSystemResumed();
156-
void onSystemGameChanged(const QString& filename, const QString& game_serial, const QString& game_title);
156+
void onSystemGameChanged(const QString& path, const QString& game_serial, const QString& game_title);
157157
void onSystemUndoStateAvailabilityChanged(bool available, quint64 timestamp);
158158
void onMediaCaptureStarted();
159159
void onMediaCaptureStopped();

src/duckstation-qt/qthost.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class EmuThread : public QThread
138138
void systemDestroyed();
139139
void systemPaused();
140140
void systemResumed();
141-
void systemGameChanged(const QString& filename, const QString& game_serial, const QString& game_title);
141+
void systemGameChanged(const QString& path, const QString& game_serial, const QString& game_title);
142142
void systemUndoStateAvailabilityChanged(bool available, quint64 timestamp);
143143
void gameListRefreshed();
144144
void gameListRowsChanged(const QList<int>& rows_changed);

0 commit comments

Comments
 (0)