From 025dcc2bb9651708d456a5b1e5d2888e67d67bf4 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 30 Jul 2009 16:04:47 +1000 Subject: Add a declarative data ptr to QObjectPrivate This data ptr does not increase the size of the QObject, as we take advantage of space otherwise only used during destruction. Reviewed-by: Andreas --- src/corelib/kernel/qobject.cpp | 8 ++++++++ src/corelib/kernel/qobject_p.h | 12 +++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index a1702d9..b0ddd81 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -842,6 +842,14 @@ QObject::~QObject() d->eventFilters.clear(); + // As declarativeData is in a union with currentChildBeingDeleted, this must + // be done (and declarativeData set back to 0) before deleting children. + if(d->declarativeData) { + QDeclarativeData *dd = d->declarativeData; + d->declarativeData = 0; + dd->destroyed(this); + } + if (!d->children.isEmpty()) d->deleteChildren(); diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 54c98ad..19df642 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -86,6 +86,13 @@ inline QObjectData::~QObjectData() {} enum { QObjectPrivateVersion = QT_VERSION }; +class QDeclarativeData +{ +public: + virtual ~QDeclarativeData() {} + virtual void destroyed(QObject *) {} +}; + class Q_CORE_EXPORT QObjectPrivate : public QObjectData { Q_DECLARE_PUBLIC(QObject) @@ -118,7 +125,10 @@ public: // object currently activating the object Sender *currentSender; - QObject *currentChildBeingDeleted; + union { + QObject *currentChildBeingDeleted; + QDeclarativeData *declarativeData; + }; bool isSender(const QObject *receiver, const char *signal) const; QObjectList receiverList(const char *signal) const; -- cgit v0.12