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; + } } }