summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-08-23 11:44:12 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-08-23 15:22:31 (GMT)
commita2f83283a64460ca26530321f8eb64f3ddfe4c8b (patch)
treec06929f2751f839245bd434b42fbe9fe8de43ee6 /src/corelib
parentd405aa6510514ce02b312994db55c305bde60285 (diff)
downloadQt-a2f83283a64460ca26530321f8eb64f3ddfe4c8b.zip
Qt-a2f83283a64460ca26530321f8eb64f3ddfe4c8b.tar.gz
Qt-a2f83283a64460ca26530321f8eb64f3ddfe4c8b.tar.bz2
Fix assignment of a container included in the container itself
Task-number: QTBUG-13079 Reviewed-by: Joao
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qhash.h5
-rw-r--r--src/corelib/tools/qlinkedlist.h5
-rw-r--r--src/corelib/tools/qlist.h5
-rw-r--r--src/corelib/tools/qmap.h5
-rw-r--r--src/corelib/tools/qvector.h5
5 files changed, 15 insertions, 10 deletions
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index 0777f06..c7e4bc1 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -589,10 +589,11 @@ template <class Key, class T>
Q_INLINE_TEMPLATE QHash<Key, T> &QHash<Key, T>::operator=(const QHash<Key, T> &other)
{
if (d != other.d) {
- other.d->ref.ref();
+ QHashData *o = other.d;
+ o->ref.ref();
if (!d->ref.deref())
freeData(d);
- d = other.d;
+ d = o;
if (!d->sharable)
detach_helper();
}
diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h
index d145fe3..9b3efa3 100644
--- a/src/corelib/tools/qlinkedlist.h
+++ b/src/corelib/tools/qlinkedlist.h
@@ -312,10 +312,11 @@ template <typename T>
QLinkedList<T> &QLinkedList<T>::operator=(const QLinkedList<T> &l)
{
if (d != l.d) {
- l.d->ref.ref();
+ QLinkedListData *o = l.d;
+ o->ref.ref();
if (!d->ref.deref())
free(d);
- d = l.d;
+ d = o;
if (!d->sharable)
detach_helper();
}
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 722744c..d843cbe 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -424,10 +424,11 @@ template <typename T>
Q_INLINE_TEMPLATE QList<T> &QList<T>::operator=(const QList<T> &l)
{
if (d != l.d) {
- l.d->ref.ref();
+ QListData::Data *o = l.d;
+ o->ref.ref();
if (!d->ref.deref())
free(d);
- d = l.d;
+ d = o;
if (!d->sharable)
detach_helper();
}
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index e4b73a1..1c2aad3 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -426,10 +426,11 @@ template <class Key, class T>
Q_INLINE_TEMPLATE QMap<Key, T> &QMap<Key, T>::operator=(const QMap<Key, T> &other)
{
if (d != other.d) {
- other.d->ref.ref();
+ QMapData* o = other.d;
+ o->ref.ref();
if (!d->ref.deref())
freeData(d);
- d = other.d;
+ d = o;
if (!d->sharable)
detach_helper();
}
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index c2e2485..b762b8a 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -377,10 +377,11 @@ inline void QVector<T>::replace(int i, const T &t)
template <typename T>
QVector<T> &QVector<T>::operator=(const QVector<T> &v)
{
- v.d->ref.ref();
+ QVectorData *o = v.d;
+ o->ref.ref();
if (!d->ref.deref())
free(p);
- d = v.d;
+ d = o;
if (!d->sharable)
detach_helper();
return *this;