diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2021-11-12 13:58:57 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2022-02-15 17:00:04 -0800 |
commit | f276f9ec6bc187a7eebbc566fa3ce37311dbe871 (patch) | |
tree | e94cb349b1ffc22031a5e11d368879b98dcfdf90 /src/corelib/serialization/qcborvalue.cpp | |
parent | ccea34464075759424e61806c7bc98ee3e658670 (diff) |
QCborValue: use assignContainer() in few more places
Change-Id: I5e52dc5b093c43a3b678fffd16b6eb65ef37399d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/serialization/qcborvalue.cpp')
-rw-r--r-- | src/corelib/serialization/qcborvalue.cpp | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/corelib/serialization/qcborvalue.cpp b/src/corelib/serialization/qcborvalue.cpp index f7bbb8e695..37a2ff6473 100644 --- a/src/corelib/serialization/qcborvalue.cpp +++ b/src/corelib/serialization/qcborvalue.cpp @@ -772,7 +772,8 @@ static QCborContainerPrivate *assignContainer(QCborContainerPrivate *&d, QCborCo return d; if (d) d->deref(); - x->ref.ref(); + if (x) + x->ref.ref(); return d = x; } @@ -1911,13 +1912,8 @@ void QCborValue::dispose() */ QCborValue &QCborValue::operator=(const QCborValue &other) { - if (other.container) - other.container->ref.ref(); - if (container) - container->deref(); - n = other.n; - container = other.container; + assignContainer(container, other.container); t = other.t; return *this; } @@ -2276,16 +2272,11 @@ static QCborContainerPrivate *maybeGrow(QCborContainerPrivate *container, qsizet { auto replace = QCborContainerPrivate::grow(container, index); Q_ASSERT(replace); - if (replace != container) { - if (container) - container->deref(); - replace->ref.ref(); - } if (replace->elements.size() == index) replace->append(Undefined()); else Q_ASSERT(replace->elements.size() > index); - return replace; + return assignContainer(container, replace); } template <typename KeyType> inline QCborValueRef |