From 113e9216844768152ebfe503e413db24fe53a1bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 10 Feb 2012 12:36:00 +0100 Subject: [PATCH] Don't expect null d-pointer in destructors The feature was introduced in commit 83497587b2 (2004, private history), to allow static containers to remain uninitialized until needed. This finishes reverting said commit. The feature had been silently removed from QByteArray and QString in commit a5a0985476 (2004, private history); removed from QList in aef03d80f7. Change-Id: I9947be7758d5730d2d6e6eb2a8a308db6e9bef39 Reviewed-by: Robin Burchell Reviewed-by: Olivier Goffart --- src/corelib/tools/qlinkedlist.h | 2 -- src/corelib/tools/qmap.h | 2 +- src/corelib/tools/qvector.h | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h index 1fa4eaabd0..28f190c7fa 100644 --- a/src/corelib/tools/qlinkedlist.h +++ b/src/corelib/tools/qlinkedlist.h @@ -241,8 +241,6 @@ private: template inline QLinkedList::~QLinkedList() { - if (!d) - return; if (!d->ref.deref()) free(d); } diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index a8306194d4..dc358a8106 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -179,7 +179,7 @@ public: inline QMap() : d(const_cast(&QMapData::shared_null)) { } inline QMap(const QMap &other) : d(other.d) { d->ref.ref(); if (!d->sharable) detach(); } - inline ~QMap() { if (!d) return; if (!d->ref.deref()) freeData(d); } + inline ~QMap() { if (!d->ref.deref()) freeData(d); } QMap &operator=(const QMap &other); #ifdef Q_COMPILER_RVALUE_REFS diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 22ce2a3d8a..6357c24621 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -126,7 +126,7 @@ public: } } - inline ~QVector() { if (!d) return; if (!d->ref.deref()) free(p); } + inline ~QVector() { if (!d->ref.deref()) free(p); } QVector &operator=(const QVector &v); #ifdef Q_COMPILER_RVALUE_REFS inline QVector operator=(QVector &&other)