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 <oswald.buddenhagen@digia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Richard Browne 2013-07-09 21:07:29 +10:00 committed by The Qt Project
parent 6c21f42657
commit 9f8a724cda

View File

@ -715,18 +715,14 @@ Q_OUTOFLINE_TEMPLATE QList<T>::QList(const QList<T> &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<Node *>(p.begin()),
reinterpret_cast<Node *>(p.end()),
reinterpret_cast<Node *>(l.p.begin()));
tryCatch.d_ = 0;
QT_TRY {
node_copy(reinterpret_cast<Node *>(p.begin()),
reinterpret_cast<Node *>(p.end()),
reinterpret_cast<Node *>(l.p.begin()));
} QT_CATCH(...) {
QListData::dispose(d);
QT_RETHROW;
}
}
}