diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2021-11-09 14:45:09 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2022-02-15 17:00:03 -0800 |
commit | 04dc959d49e5e3742db759c131a0a78f21821653 (patch) | |
tree | c78573cbef0c41ad6cc579c5f31597060916081b /src/corelib/serialization/qjsonobject.h | |
parent | 9b8f064cd36e014ecb3e6b60e2190b74f69aee5a (diff) |
Introduce Q{Json,Cbor}ValueConstRef
I screwed up when I wrote QCborValueRef by not having the ConstRef
type. The code worked, but it wasn't const-correct, allowing you to
write:
const QCborArray &arr = something();
*arr.begin() = QCborArray();
This mistake was brought over to QJsonValue in Qt 6.0, so it has to be
fixed for QJsonValue too. The actual fixes are in the next couple of
commits.
This change is believed to be binary-compatible: the Q{Json,Cbor}ValueRef
classes continue to have the exact same size, except that they're now
empty and have a new base class. They weren't trivial before this commit
doesn't change that.
[ChangeLog][Potentially Source-Incompatible Changes] The iterator
classes for Qt's JSON and CBOR containers (array and map/object) had a
const correctness issue which allowed a const_iterator to mutate the
container being iterated on, even if that container was itself const. Qt
6.4 has a fix for this, but will cause compilation issues where
QCborValueRef and QJsonValueRef were used where the correctness could be
violated. To keep code compiling with both 6.3 and 6.4, either change to
non-const iteration or replace the QxxxValueRef with a const QxxxValue
reference. This change is binary-compatible.
Change-Id: I5e52dc5b093c43a3b678fffd16b6063333765ae0
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'src/corelib/serialization/qjsonobject.h')
-rw-r--r-- | src/corelib/serialization/qjsonobject.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/corelib/serialization/qjsonobject.h b/src/corelib/serialization/qjsonobject.h index 25912779ed..5c0cc1f5dc 100644 --- a/src/corelib/serialization/qjsonobject.h +++ b/src/corelib/serialization/qjsonobject.h @@ -283,6 +283,7 @@ public: private: friend class QJsonValue; friend class QJsonDocument; + friend class QJsonValueConstRef; friend class QJsonValueRef; friend class QCborMap; friend Q_CORE_EXPORT QDebug operator<<(QDebug, const QJsonObject &); |