summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2020-04-08 12:13:55 -0300
committerThiago Macieira <thiago.macieira@intel.com>2020-04-11 12:04:25 +0000
commitbfb9b02d3b36244dc19c94a5693071a738bac8a2 (patch)
tree4da555e1dd31c2f4567a6a179445cd7ceb14a7c7 /src/corelib/serialization
parent1ec350e35fcea87c527b36cf429b595731059240 (diff)
QCborValue: fix the move-assignment operatorv5.15.0-beta4
The double-swap technique I used was flawed and broke on self-assignment. What I had meant to use was the move-and-swap technique. Thanks to Peppe for pointing it out. This also fixes a compiler bug in the Green Hills compiler. It was finding the wrong "swap" function in qSwap: using std::swap; swap(value1, value2); It's supposed to find swap(QCborValue &, QCborValue &) due to argument- dependent lookup. It's instead finding std::swap<QCborValue>, which recurses. Fixes: QTBUG-83390 Change-Id: Ibdc95e9af7bd456a94ecfffd1603e1bee90cd107 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/corelib/serialization')
-rw-r--r--src/corelib/serialization/qcborvalue.h5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/corelib/serialization/qcborvalue.h b/src/corelib/serialization/qcborvalue.h
index f7064ac6e1..aa51e5da81 100644
--- a/src/corelib/serialization/qcborvalue.h
+++ b/src/corelib/serialization/qcborvalue.h
@@ -188,9 +188,8 @@ public:
QCborValue &operator=(const QCborValue &other);
QCborValue &operator=(QCborValue &&other) noexcept
{
- QCborValue tmp;
- qSwap(*this, tmp);
- qSwap(other, *this);
+ QCborValue tmp(std::move(other));
+ swap(tmp);
return *this;
}