From 2b70a7d25c3e73d02d6d14075790668dcfc16e64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 21 Feb 2012 14:48:47 +0100 Subject: QList: have operator= defer to copy-ctor and swap Change-Id: I0f9bdbc444abfaea35278281b6c1dff4b52c526f Reviewed-by: Bradley T. Hughes --- src/corelib/tools/qlist.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src/corelib/tools/qlist.h') diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 08dedb4e94..798351cd61 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -419,13 +419,8 @@ template Q_INLINE_TEMPLATE QList &QList::operator=(const QList &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 tmp(l); + tmp.swap(*this); } return *this; } -- cgit v1.2.3