Add QIconLoader debug logging to aid fallback logic investigation
The icon loader machinery is a bit opaque, so let's add some logging to understand the interactions. Change-Id: Ic400b6043607795ad92771f9d9f189699f185366 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit 798456c0a39468c41784817435a2cf622d0f9b12) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
3ef4dbf2ee
commit
40db6d0715
@ -14,6 +14,7 @@
|
|||||||
#include <QtCore/qmath.h>
|
#include <QtCore/qmath.h>
|
||||||
#include <QtCore/QList>
|
#include <QtCore/QList>
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
|
#include <QtCore/qloggingcategory.h>
|
||||||
#if QT_CONFIG(settings)
|
#if QT_CONFIG(settings)
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
#endif
|
#endif
|
||||||
@ -23,6 +24,8 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(lcIconLoader, "qt.gui.icon.loader")
|
||||||
|
|
||||||
using namespace Qt::StringLiterals;
|
using namespace Qt::StringLiterals;
|
||||||
|
|
||||||
Q_GLOBAL_STATIC(QIconLoader, iconLoaderInstance)
|
Q_GLOBAL_STATIC(QIconLoader, iconLoaderInstance)
|
||||||
@ -90,6 +93,9 @@ void QIconLoader::ensureInitialized()
|
|||||||
m_systemTheme = systemFallbackThemeName();
|
m_systemTheme = systemFallbackThemeName();
|
||||||
if (qt_iconEngineFactoryLoader()->keyMap().key("svg"_L1, -1) != -1)
|
if (qt_iconEngineFactoryLoader()->keyMap().key("svg"_L1, -1) != -1)
|
||||||
m_supportsSvg = true;
|
m_supportsSvg = true;
|
||||||
|
|
||||||
|
qCDebug(lcIconLoader) << "Initialized icon loader with system theme"
|
||||||
|
<< m_systemTheme << "and SVG support" << m_supportsSvg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,8 +126,12 @@ void QIconLoader::updateSystemTheme()
|
|||||||
theme = fallbackThemeName();
|
theme = fallbackThemeName();
|
||||||
if (theme != m_systemTheme) {
|
if (theme != m_systemTheme) {
|
||||||
m_systemTheme = theme;
|
m_systemTheme = theme;
|
||||||
|
qCDebug(lcIconLoader) << "Updated system theme to" << m_systemTheme;
|
||||||
invalidateKey();
|
invalidateKey();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
qCDebug(lcIconLoader) << "Ignoring system theme update because"
|
||||||
|
<< "user theme" << m_userTheme << "has been set";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,6 +147,8 @@ void QIconLoader::setThemeName(const QString &themeName)
|
|||||||
if (m_userTheme == themeName)
|
if (m_userTheme == themeName)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
qCDebug(lcIconLoader) << "Setting user theme name to" << themeName;
|
||||||
|
|
||||||
m_userTheme = themeName;
|
m_userTheme = themeName;
|
||||||
invalidateKey();
|
invalidateKey();
|
||||||
}
|
}
|
||||||
@ -148,11 +160,13 @@ QString QIconLoader::fallbackThemeName() const
|
|||||||
|
|
||||||
void QIconLoader::setFallbackThemeName(const QString &themeName)
|
void QIconLoader::setFallbackThemeName(const QString &themeName)
|
||||||
{
|
{
|
||||||
|
qCDebug(lcIconLoader) << "Setting fallback theme name to" << themeName;
|
||||||
m_userFallbackTheme = themeName;
|
m_userFallbackTheme = themeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QIconLoader::setThemeSearchPath(const QStringList &searchPaths)
|
void QIconLoader::setThemeSearchPath(const QStringList &searchPaths)
|
||||||
{
|
{
|
||||||
|
qCDebug(lcIconLoader) << "Setting theme search path to" << searchPaths;
|
||||||
m_iconDirs = searchPaths;
|
m_iconDirs = searchPaths;
|
||||||
themeList.clear();
|
themeList.clear();
|
||||||
invalidateKey();
|
invalidateKey();
|
||||||
@ -170,6 +184,7 @@ QStringList QIconLoader::themeSearchPaths() const
|
|||||||
|
|
||||||
void QIconLoader::setFallbackSearchPaths(const QStringList &searchPaths)
|
void QIconLoader::setFallbackSearchPaths(const QStringList &searchPaths)
|
||||||
{
|
{
|
||||||
|
qCDebug(lcIconLoader) << "Setting fallback search path to" << searchPaths;
|
||||||
m_fallbackDirs = searchPaths;
|
m_fallbackDirs = searchPaths;
|
||||||
invalidateKey();
|
invalidateKey();
|
||||||
}
|
}
|
||||||
@ -391,10 +406,19 @@ QIconTheme::QIconTheme(const QString &themeName)
|
|||||||
#endif // settings
|
#endif // settings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QDebug operator<<(QDebug debug, const std::unique_ptr<QIconLoaderEngineEntry> &entry)
|
||||||
|
{
|
||||||
|
QDebugStateSaver saver(debug);
|
||||||
|
debug.noquote() << entry->filename;
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
|
||||||
QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
|
QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
|
||||||
const QString &iconName,
|
const QString &iconName,
|
||||||
QStringList &visited) const
|
QStringList &visited) const
|
||||||
{
|
{
|
||||||
|
qCDebug(lcIconLoader) << "Finding icon" << iconName << "in theme" << themeName;
|
||||||
|
|
||||||
QThemeIconInfo info;
|
QThemeIconInfo info;
|
||||||
Q_ASSERT(!themeName.isEmpty());
|
Q_ASSERT(!themeName.isEmpty());
|
||||||
|
|
||||||
@ -404,9 +428,12 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
|
|||||||
QIconTheme &theme = themeList[themeName];
|
QIconTheme &theme = themeList[themeName];
|
||||||
if (!theme.isValid()) {
|
if (!theme.isValid()) {
|
||||||
theme = QIconTheme(themeName);
|
theme = QIconTheme(themeName);
|
||||||
if (!theme.isValid())
|
if (!theme.isValid()) {
|
||||||
|
qCDebug(lcIconLoader) << "Theme" << themeName << "not found;"
|
||||||
|
<< "trying fallback theme" << fallbackThemeName();
|
||||||
theme = QIconTheme(fallbackThemeName());
|
theme = QIconTheme(fallbackThemeName());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const QStringList contentDirs = theme.contentDirs();
|
const QStringList contentDirs = theme.contentDirs();
|
||||||
|
|
||||||
@ -481,6 +508,10 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
|
|||||||
|
|
||||||
if (info.entries.empty()) {
|
if (info.entries.empty()) {
|
||||||
const QStringList parents = theme.parents();
|
const QStringList parents = theme.parents();
|
||||||
|
qCDebug(lcIconLoader) << "Did not find matching icons in theme;"
|
||||||
|
<< "trying parent themes" << parents
|
||||||
|
<< "skipping visited" << visited;
|
||||||
|
|
||||||
// Search recursively through inherited themes
|
// Search recursively through inherited themes
|
||||||
for (int i = 0 ; i < parents.size() ; ++i) {
|
for (int i = 0 ; i < parents.size() ; ++i) {
|
||||||
|
|
||||||
@ -493,11 +524,14 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
QThemeIconInfo QIconLoader::lookupFallbackIcon(const QString &iconName) const
|
QThemeIconInfo QIconLoader::lookupFallbackIcon(const QString &iconName) const
|
||||||
{
|
{
|
||||||
|
qCDebug(lcIconLoader) << "Looking up fallback icon" << iconName;
|
||||||
|
|
||||||
QThemeIconInfo info;
|
QThemeIconInfo info;
|
||||||
|
|
||||||
const QString pngIconName = iconName + ".png"_L1;
|
const QString pngIconName = iconName + ".png"_L1;
|
||||||
@ -536,16 +570,18 @@ QThemeIconInfo QIconLoader::lookupFallbackIcon(const QString &iconName) const
|
|||||||
|
|
||||||
QThemeIconInfo QIconLoader::loadIcon(const QString &name) const
|
QThemeIconInfo QIconLoader::loadIcon(const QString &name) const
|
||||||
{
|
{
|
||||||
|
qCDebug(lcIconLoader) << "Loading icon" << name;
|
||||||
|
|
||||||
|
QThemeIconInfo iconInfo;
|
||||||
if (!themeName().isEmpty()) {
|
if (!themeName().isEmpty()) {
|
||||||
QStringList visited;
|
QStringList visited;
|
||||||
QThemeIconInfo iconInfo = findIconHelper(themeName(), name, visited);
|
iconInfo = findIconHelper(themeName(), name, visited);
|
||||||
if (!iconInfo.entries.empty())
|
if (iconInfo.entries.empty())
|
||||||
return iconInfo;
|
iconInfo = lookupFallbackIcon(name);
|
||||||
|
|
||||||
return lookupFallbackIcon(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return QThemeIconInfo();
|
qCDebug(lcIconLoader) << "Resulting icon entries" << iconInfo.entries;
|
||||||
|
return iconInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user