diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2023-09-04 18:49:12 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2023-09-05 22:41:35 +0200 |
commit | 40b07ee887d9717088e3189b15c86a5c87759b1d (patch) | |
tree | 74c8a0fec318602f4d5cbac6b563529b83504556 /examples/corelib/serialization | |
parent | d631f888042e3f3f5d4d0284c6bad8eb91e2c9a3 (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.
Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: Ib6aa16e8c834f89c6ccc0715f20b0e5f0a7f3b6d
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Diffstat (limited to 'examples/corelib/serialization')
-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(); |