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/qcborarray.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/qcborarray.h')
-rw-r--r-- | src/corelib/serialization/qcborarray.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/corelib/serialization/qcborarray.h b/src/corelib/serialization/qcborarray.h index be22af3985..9e49676335 100644 --- a/src/corelib/serialization/qcborarray.h +++ b/src/corelib/serialization/qcborarray.h @@ -288,6 +288,7 @@ inline QCborValue::QCborValue(QCborArray &&a) { } +#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && !defined(QT_BOOTSTRAPPED) inline QCborArray QCborValueRef::toArray() const { return concrete().toArray(); @@ -297,6 +298,17 @@ inline QCborArray QCborValueRef::toArray(const QCborArray &a) const { return concrete().toArray(a); } +#endif + +inline QCborArray QCborValueConstRef::toArray() const +{ + return concrete().toArray(); +} + +inline QCborArray QCborValueConstRef::toArray(const QCborArray &a) const +{ + return concrete().toArray(a); +} Q_CORE_EXPORT size_t qHash(const QCborArray &array, size_t seed = 0); |