summaryrefslogtreecommitdiffstats
path: root/examples/corelib/serialization/convert/jsonconverter.cpp
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2023-10-31 16:10:55 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2023-11-01 21:28:55 +0100
commit0b1670134b43ba390f35b52d2458e4269a804de3 (patch)
tree5dac215fa096cd99064a73cfdf6a68e3dcc8249d /examples/corelib/serialization/convert/jsonconverter.cpp
parent0de55973d37a951fb5d5f596d7967f1978865845 (diff)
Replace confusing member variable with a predicate
The Converter class, in the eponymous example, had a null member variable that wasn't a nullptr - it pointed to an instance of NullConverter - so that other converters could test whether a Converter * they'd been passed was null (in the sense of pointing to a NullConverter). This, however, was susceptible to misreading - I misread one such comparison as a nullptr check and thus thought it redundant with an earlier actual nullptr check. To spare future readers similar confusion, replace the public static member variable with a protected (since only other derived classes need it) static predicate, to at least give the reader a clue that this is using the word null in a class-specific sense. Pick-to: 6.6 6.5 Task-number: QTBUG-111228 Change-Id: I1e4f494b303d1bf90107f8c6fa3a4a22f6d81b90 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'examples/corelib/serialization/convert/jsonconverter.cpp')
-rw-r--r--examples/corelib/serialization/convert/jsonconverter.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/examples/corelib/serialization/convert/jsonconverter.cpp b/examples/corelib/serialization/convert/jsonconverter.cpp
index 6c307cdb8c..611061705b 100644
--- a/examples/corelib/serialization/convert/jsonconverter.cpp
+++ b/examples/corelib/serialization/convert/jsonconverter.cpp
@@ -76,7 +76,7 @@ QVariant JsonConverter::loadFile(QIODevice *f, const Converter *&outputConverter
qFatal("Could not parse JSON content: offset %d: %s",
error.offset, qPrintable(error.errorString()));
}
- if (outputConverter == null)
+ if (isNull(outputConverter))
return QVariant();
return doc.toVariant();
}