diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2023-09-04 18:49:12 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-09-05 20:42:00 +0000 |
commit | 4b395965129b91aa2c616539cc5500393063c8e1 (patch) | |
tree | de29dc1b37940128545c4cded19ea13d054a9666 /examples | |
parent | 19242733aa7bf0cba8684ed217476a28a0eebe49 (diff) |
Minor tidies in example's XML converter
Make a local variable more local, set a variable only once its new
value is known to be valid.
Task-number: QTBUG-111228
Change-Id: Ib6aa16e8c834f89c6ccc0715f20b0e5f0a7f3b6d
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
(cherry picked from commit 40b07ee887d9717088e3189b15c86a5c87759b1d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/corelib/serialization/convert/xmlconverter.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/examples/corelib/serialization/convert/xmlconverter.cpp b/examples/corelib/serialization/convert/xmlconverter.cpp index 080528f678..9d08be2e55 100644 --- a/examples/corelib/serialization/convert/xmlconverter.cpp +++ b/examples/corelib/serialization/convert/xmlconverter.cpp @@ -180,23 +180,23 @@ static QVariant variantFromXml(QXmlStreamReader &xml, Converter::Options options text = text.trimmed(); QVariant result; - bool ok; if (type.isEmpty()) { // ok } else if (type == QLatin1String("number")) { // try integer first + bool ok; qint64 v = text.toLongLong(&ok); if (ok) { result = v; } else { // let's see floating point double d = text.toDouble(&ok); - result = d; if (!ok) { fprintf(stderr, "%lld:%lld: Invalid XML: could not interpret '%s' as a number.\n", xml.lineNumber(), xml.columnNumber(), qPrintable(text.toString())); exit(EXIT_FAILURE); } + result = d; } } else if (type == QLatin1String("bytes")) { QByteArray data = text.toLatin1(); |