QList: have operator= defer to copy-ctor and swap
authorJoão Abecasis <joao.abecasis@nokia.com>
Tue, 21 Feb 2012 13:48:47 +0000 (14:48 +0100)
committerQt by Nokia <qt-info@nokia.com>
Wed, 29 Feb 2012 15:25:13 +0000 (16:25 +0100)
Change-Id: I0f9bdbc444abfaea35278281b6c1dff4b52c526f
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
src/corelib/tools/qlist.h

index 08dedb4..798351c 100644 (file)
@@ -419,13 +419,8 @@ template <typename T>
 Q_INLINE_TEMPLATE QList<T> &QList<T>::operator=(const QList<T> &l)
 {
     if (d != l.d) {
-        QListData::Data *o = l.d;
-        o->ref.ref();
-        if (!d->ref.deref())
-            dealloc(d);
-        d = o;
-        if (!d->sharable)
-            detach_helper();
+        QList<T> tmp(l);
+        tmp.swap(*this);
     }
     return *this;
 }