Don't call delete later unless you have to

This commit is contained in:
Atlante45 2015-01-09 15:32:08 -08:00
parent 336378679f
commit 6d67b8e20c

View file

@ -13,6 +13,7 @@
#define hifi_DependencyManager_h #define hifi_DependencyManager_h
#include <QSharedPointer> #include <QSharedPointer>
#include <QDebug>
#include <typeinfo> #include <typeinfo>
@ -22,10 +23,12 @@ public:\
private:\ private:\
void customDeleter() {\ void customDeleter() {\
QObject* thisObject = dynamic_cast<QObject*>(this);\ QObject* thisObject = dynamic_cast<QObject*>(this);\
if (thisObject) {\ if (thisObject && thisObject->parent()) {\
thisObject->deleteLater();\ thisObject->deleteLater();\
qDebug() << "Delete later:" << #T;\
} else {\ } else {\
delete this;\ delete this;\
qDebug() << "Deleted:" << #T;\
}\ }\
}\ }\
friend class DependencyManager; friend class DependencyManager;