From 9f8a724cda6783ca275fb810e7d1fc05bf840e2e Mon Sep 17 00:00:00 2001 From: Richard Browne Date: Tue, 9 Jul 2013 21:07:29 +1000 Subject: [PATCH] Work around msvc /clr LNK2005 errors with QList This patch fixes a compatibility with Qt 5 and Microsoft C++ /clr mode. The QList copy constructor defines a Cleanup class that causes LNK2005 errors. It is a compiler problem, but the patch is simple. The use of QT_TRY/QT_RETHROW instead of a Cleanup class is more consistent with other Qt code, so is arguably preferable even without the compiler bug. Task-number: QTBUG-31949 Change-Id: I1acfbae1924f0a52ffb8d9722b52e01b61edd42e Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- src/corelib/tools/qlist.h | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 0592c24e9f..72e1403e76 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -715,18 +715,14 @@ Q_OUTOFLINE_TEMPLATE QList::QList(const QList &l) if (!d->ref.ref()) { p.detach(d->alloc); - struct Cleanup - { - Cleanup(QListData::Data *d) : d_(d) {} - ~Cleanup() { if (d_) QListData::dispose(d_); } - - QListData::Data *d_; - } tryCatch(d); - - node_copy(reinterpret_cast(p.begin()), - reinterpret_cast(p.end()), - reinterpret_cast(l.p.begin())); - tryCatch.d_ = 0; + QT_TRY { + node_copy(reinterpret_cast(p.begin()), + reinterpret_cast(p.end()), + reinterpret_cast(l.p.begin())); + } QT_CATCH(...) { + QListData::dispose(d); + QT_RETHROW; + } } }