diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h index 3469ebe5e6..0564683f48 100644 --- a/src/corelib/global/qconfig-bootstrapped.h +++ b/src/corelib/global/qconfig-bootstrapped.h @@ -99,6 +99,7 @@ #define QT_FEATURE_process -1 #define QT_FEATURE_regularexpression -1 #define QT_FEATURE_renameat2 -1 +#define QT_FEATURE_settings -1 #define QT_FEATURE_sharedmemory -1 #define QT_FEATURE_slog2 -1 #define QT_FEATURE_statx -1 diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index cd97268d71..9792d956cc 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -46,6 +46,11 @@ #include #include +#if QT_CONFIG(settings) +#include +#include +#endif + // We can't use the default macros because this would lead to recursion. // Instead let's define our own one that unconditionally logs... #define debugMsg QMessageLogger(__FILE__, __LINE__, __FUNCTION__, "qt.core.logging").debug @@ -230,7 +235,14 @@ void QLoggingSettingsParser::parseNextLine(QStringRef line) int equalPos = line.indexOf(QLatin1Char('=')); if (equalPos != -1) { if (line.lastIndexOf(QLatin1Char('=')) == equalPos) { - const auto pattern = line.left(equalPos).trimmed(); + const auto key = line.left(equalPos).trimmed(); +#if QT_CONFIG(settings) + QString tmp; + QSettingsPrivate::iniUnescapedKey(key.toUtf8(), 0, key.length(), tmp); + QStringRef pattern = QStringRef(&tmp, 0, tmp.length()); +#else + QStringRef pattern = key; +#endif const auto valueStr = line.mid(equalPos + 1).trimmed(); int value = -1; if (valueStr == QLatin1String("true")) diff --git a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp index 5b61a6007d..a10e706ed7 100644 --- a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp +++ b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp @@ -187,6 +187,13 @@ private slots: "default=false"); QCOMPARE(parser.rules().size(), 1); + // QSettings escapes * to %2A when writing. + parser.setContent("[Rules]\n" + "module.%2A=false"); + QCOMPARE(parser.rules().size(), 1); + QCOMPARE(parser.rules().first().category, QString("module.")); + QCOMPARE(parser.rules().first().flags, QLoggingRule::LeftFilter); + parser.setContent("[OtherSection]\n" "default=false"); QCOMPARE(parser.rules().size(), 0);