From fa22138afd8c9f3c97735b61f72f61580fa94091 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Fri, 10 Jul 2015 14:44:48 +0900 Subject: [PATCH] Add warning for malformed logging rule Change-Id: I58ccbb77e5ab62e4114a271f199797dd1307a676 Reviewed-by: Kai Koehne --- src/corelib/io/qloggingregistry.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index 7f2ce319ee..11fe32529f 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -210,20 +210,23 @@ void QLoggingSettingsParser::setContent(QTextStream &stream) if (_section == QLatin1String("Rules")) { int equalPos = line.indexOf(QLatin1Char('=')); - if ((equalPos != -1) - && (line.lastIndexOf(QLatin1Char('=')) == equalPos)) { - const QStringRef pattern = line.leftRef(equalPos); - const QStringRef valueStr = line.midRef(equalPos + 1); - int value = -1; - if (valueStr == QLatin1String("true")) - value = 1; - else if (valueStr == QLatin1String("false")) - value = 0; - QLoggingRule rule(pattern, (value == 1)); - if (rule.flags != 0 && (value != -1)) - _rules.append(rule); - else + if (equalPos != -1) { + if (line.lastIndexOf(QLatin1Char('=')) == equalPos) { + const QStringRef pattern = line.leftRef(equalPos); + const QStringRef valueStr = line.midRef(equalPos + 1); + int value = -1; + if (valueStr == QLatin1String("true")) + value = 1; + else if (valueStr == QLatin1String("false")) + value = 0; + QLoggingRule rule(pattern, (value == 1)); + if (rule.flags != 0 && (value != -1)) + _rules.append(rule); + else + warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData()); + } else { warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData()); + } } } }