diff options
| author | Ivan Solovev <ivan.solovev@qt.io> | 2024-08-27 10:30:24 +0200 |
|---|---|---|
| committer | Marc Mutz <marc.mutz@qt.io> | 2024-08-28 13:07:20 +0000 |
| commit | 7f01b62969d1734832ead0547904902ae0f1b5dd (patch) | |
| tree | f27d4fb27ce5378ded35f70387f6b8d91220d3b1 /src/corelib/serialization/qjsonobject.h | |
| parent | 495a06a22aef2aa62dd993217e4f4ec099ad4e94 (diff) | |
serialization: remove incorrect noexcept on comparison operators [1/2]
QJsonValue comparison cannot be noexcept, because it might allocate,
for example when calling QCborValue::toString(). As a result, all
the QJsonValue(Const)Ref comparison operators also cannot be
noexcept, because they convert to QJsonValue to do the comparison.
QJsonObject comparison cannot be noexcept, because it might call
QCborValue::makeValue(), which might allocate.
QJsonArray comparison cannot be noexcept, because it might also
call QCborValue::makeValue(), which might allocate.
Found in 6.8 API review.
Pick-to: 6.8
Change-Id: I775746b2a76765bca26b87d5af396a8dfdfca7f9
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/serialization/qjsonobject.h')
| -rw-r--r-- | src/corelib/serialization/qjsonobject.h | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/corelib/serialization/qjsonobject.h b/src/corelib/serialization/qjsonobject.h index 4cdbf4511d9..a0b8328b1b9 100644 --- a/src/corelib/serialization/qjsonobject.h +++ b/src/corelib/serialization/qjsonobject.h @@ -313,20 +313,18 @@ public: private: friend Q_CORE_EXPORT bool comparesEqual(const QJsonObject &lhs, - const QJsonObject &rhs) noexcept; - friend bool comparesEqual(const QJsonObject &lhs, - const QJsonValue &rhs) noexcept + const QJsonObject &rhs); + friend bool comparesEqual(const QJsonObject &lhs, const QJsonValue &rhs) { return comparesEqual(lhs, rhs.toObject()); } - friend bool comparesEqual(const QJsonObject &lhs, - const QJsonValueConstRef &rhs) noexcept + friend bool comparesEqual(const QJsonObject &lhs, const QJsonValueConstRef &rhs) { return comparesEqual(lhs, rhs.toObject()); } - Q_DECLARE_EQUALITY_COMPARABLE(QJsonObject) - Q_DECLARE_EQUALITY_COMPARABLE(QJsonObject, QJsonValue) - Q_DECLARE_EQUALITY_COMPARABLE(QJsonObject, QJsonValueConstRef) + Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(QJsonObject) + Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(QJsonObject, QJsonValue) + Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(QJsonObject, QJsonValueConstRef) friend class QJsonValue; friend class QJsonDocument; friend class QJsonPrivate::Value; |
