From 62153d6ce031826895d1d1da60e256693783ff4f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 25 Mar 2025 14:24:49 -0700 Subject: [PATCH] QLoggingRegistry: load all the qtlogging.ini files, not just the first MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QStandardPaths::locate() returns the first item that locateAll() would have returned, which may be the user's override file. However, if this file exists, it completely disables loading of the system files, so any rules present there would be ignored, a behavior different from the qtlogging.ini installed in the Qt DATADIR. That means we now match what the documentation said we'd do: The \c QtProject/qtlogging.ini file is looked up in all directories returned by QStandardPaths::GenericConfigLocation. [ChangeLog][QtCore][Logging framework] Fixed a bug that caused the logging framework to not load all the QtProject/qtlogging.ini files found in the user and system configurations. Previously, it would stop parsing after finding the first one; now, all files are processed and their rules are merged. See the QStandardPaths documentation for more information on what file paths are considered in each operating system. Change-Id: I7f6ea7e173e6dc9a8350fffde601bb2ca826a148 Reviewed-by: Kai Köhne Reviewed-by: David Faure --- src/corelib/io/qloggingregistry.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index 62fffc6ab7e..da8ed80ff16 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -309,10 +309,12 @@ void QLoggingRegistry::initializeRules() qr = loadRulesFromFile(qtConfigPath); // get rules from user's/system configuration - const QString envPath = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, - QString::fromLatin1("QtProject/") + configFileName); - if (!envPath.isEmpty()) - cr = loadRulesFromFile(envPath); + // locateAll() returns the user's file (most overriding) first + const QStringList configPaths = + QStandardPaths::locateAll(QStandardPaths::GenericConfigLocation, + QString::fromLatin1("QtProject/") + configFileName); + for (qsizetype i = configPaths.size(); i > 0; --i) + cr += loadRulesFromFile(configPaths[i - 1]); const QMutexLocker locker(®istryMutex);