Skip to content

Commit

Permalink
Reset icon theme name before calling QIcon::fromTheme().
Browse files Browse the repository at this point in the history
qt5ct randomly resets the active Qt icon theme to "",
resulting in empty or wrong icons.

See https://sourceforge.net/p/qt5ct/tickets/80/

Fixes #4963
  • Loading branch information
phoerious authored and lerignoux committed Jul 20, 2020
1 parent 6d97cf8 commit 83659e6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/core/Resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ QIcon Resources::icon(const QString& name, bool recolor, const QColor& overrideC
return icon;
}

// Resetting the application theme name before calling QIcon::fromTheme() is required for hacky
// QPA platform themes such as qt5ct, which randomly mess with the configured icon theme.
// If we do not reset the theme name here, it will become empty at some point, causing
// Qt to look for icons at the user-level and global default locations.
//
// See issue #4963: https://github.com/keepassxreboot/keepassxc/issues/4963
// and qt5ct issue #80: https://sourceforge.net/p/qt5ct/tickets/80/
QIcon::setThemeName("application");

icon = QIcon::fromTheme(name);
if (getMainWindow() && recolor) {
QImage img = icon.pixmap(128, 128).toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);
Expand Down

0 comments on commit 83659e6

Please sign in to comment.