From c0eb81664f2bae225dcaca897c23564d6f97a3d1 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 15 Apr 2010 12:51:51 +1000 Subject: Add QML object destruction hook --- src/declarative/qml/qdeclarativeengine.cpp | 4 ++++ src/declarative/qml/qdeclarativeprivate.h | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index c5afe92..85e8a9e 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -350,6 +350,10 @@ typedef QMap StringStringMap; Q_GLOBAL_STATIC(StringStringMap, qmlEnginePluginsWithRegisteredTypes); // stores the uri +void QDeclarativePrivate::qdeclarativeelement_destructor(QObject *) +{ +} + void QDeclarativeDeclarativeData::destroyed(QDeclarativeData *d, QObject *o) { static_cast(d)->destroyed(o); diff --git a/src/declarative/qml/qdeclarativeprivate.h b/src/declarative/qml/qdeclarativeprivate.h index bebe82c..6e240d8 100644 --- a/src/declarative/qml/qdeclarativeprivate.h +++ b/src/declarative/qml/qdeclarativeprivate.h @@ -69,11 +69,18 @@ public: class QDeclarativeCustomParser; namespace QDeclarativePrivate { + void Q_DECLARATIVE_EXPORT qdeclarativeelement_destructor(QObject *); template - QObject *create() { return new T; } + class QDeclarativeElement : public T + { + public: + virtual ~QDeclarativeElement() { + QDeclarativePrivate::qdeclarativeelement_destructor(this); + } + }; template - void createInto(void *memory) { new (memory) T; } + void createInto(void *memory) { new (memory) QDeclarativeElement; } template QObject *createParent(QObject *p) { return new T(p); } -- cgit v0.12