From e790af0e0a030dea597bbc9489170b5ba1cf9e46 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 10 Aug 2020 10:25:41 -0700 Subject: QJsonDocument: fix comparison of valid vs default [ChangeLog][QtCore][QJsonDocument] Fixed a bug that caused QJsonDocument's equality operator to crash if one of the operands was default-constructed and the other wasn't. Pick-to: 5.15 Fixes: QTBUG-85969 Change-Id: I5e00996d7f4b4a10bc98fffd1629f835f570ef6b Reviewed-by: Sona Kurazyan --- src/corelib/serialization/qjsondocument.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/corelib/serialization') diff --git a/src/corelib/serialization/qjsondocument.cpp b/src/corelib/serialization/qjsondocument.cpp index 579bb70a2b..6ec169da62 100644 --- a/src/corelib/serialization/qjsondocument.cpp +++ b/src/corelib/serialization/qjsondocument.cpp @@ -495,7 +495,9 @@ const QJsonValue QJsonDocument::operator[](int i) const */ bool QJsonDocument::operator==(const QJsonDocument &other) const { - return (!d) ? (!other.d) : (d->value == other.d->value); + if (d && other.d) + return d->value == other.d->value; + return !d == !other.d; } /*! -- cgit v1.2.3