Add warning for malformed logging rule

Change-Id: I58ccbb77e5ab62e4114a271f199797dd1307a676
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
This commit is contained in:
Tasuku Suzuki 2015-07-10 14:44:48 +09:00 committed by Kai Koehne
parent 0dd14aaaf1
commit fa22138afd

View File

@ -210,20 +210,23 @@ void QLoggingSettingsParser::setContent(QTextStream &stream)
if (_section == QLatin1String("Rules")) { if (_section == QLatin1String("Rules")) {
int equalPos = line.indexOf(QLatin1Char('=')); int equalPos = line.indexOf(QLatin1Char('='));
if ((equalPos != -1) if (equalPos != -1) {
&& (line.lastIndexOf(QLatin1Char('=')) == equalPos)) { if (line.lastIndexOf(QLatin1Char('=')) == equalPos) {
const QStringRef pattern = line.leftRef(equalPos); const QStringRef pattern = line.leftRef(equalPos);
const QStringRef valueStr = line.midRef(equalPos + 1); const QStringRef valueStr = line.midRef(equalPos + 1);
int value = -1; int value = -1;
if (valueStr == QLatin1String("true")) if (valueStr == QLatin1String("true"))
value = 1; value = 1;
else if (valueStr == QLatin1String("false")) else if (valueStr == QLatin1String("false"))
value = 0; value = 0;
QLoggingRule rule(pattern, (value == 1)); QLoggingRule rule(pattern, (value == 1));
if (rule.flags != 0 && (value != -1)) if (rule.flags != 0 && (value != -1))
_rules.append(rule); _rules.append(rule);
else else
warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData());
} else {
warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData()); warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData());
}
} }
} }
} }