summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/tools/qcontiguouscache.h2
-rw-r--r--tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp12
2 files changed, 13 insertions, 1 deletions
diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h
index fc4fb1e7cb..41d198f9bc 100644
--- a/src/corelib/tools/qcontiguouscache.h
+++ b/src/corelib/tools/qcontiguouscache.h
@@ -291,7 +291,7 @@ QContiguousCache<T> &QContiguousCache<T>::operator=(const QContiguousCache<T> &o
{
other.d->ref.ref();
if (!d->ref.deref())
- freeData(d);
+ freeData(p);
d = other.d;
if (!d->sharable)
detach_helper();
diff --git a/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp b/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp
index 01855a730e..76687bd478 100644
--- a/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp
+++ b/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp
@@ -43,6 +43,8 @@ class tst_QContiguousCache : public QObject
{
Q_OBJECT
private slots:
+ void assignment();
+
void empty();
void swap();
@@ -64,6 +66,16 @@ private slots:
QTEST_MAIN(tst_QContiguousCache)
+void tst_QContiguousCache::assignment()
+{
+ // compile-only test: QTBUG-45783
+ QContiguousCache<int> cc1, cc2;
+ // copy:
+ cc1 = cc2;
+ // move:
+ cc1 = qMove(cc2);
+}
+
void tst_QContiguousCache::empty()
{
QContiguousCache<int> c(10);