summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-04-27 05:36:11 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-04-27 05:36:11 (GMT)
commit9f941fd65083ae6d3f2f5441bf60346821932218 (patch)
tree4ccd25dd9de4835a551534de37a931e2105fa4d3 /src/corelib/kernel
parentf75b524b060682a896ac7a3951ac677d29e15727 (diff)
downloadQt-9f941fd65083ae6d3f2f5441bf60346821932218.zip
Qt-9f941fd65083ae6d3f2f5441bf60346821932218.tar.gz
Qt-9f941fd65083ae6d3f2f5441bf60346821932218.tar.bz2
Add a declarative data ptr to QObjectPrivate
This data ptr does not increase the size of the QObject, as we take advantage of space only used during destruction. Currently this data is only used to store an object's QmlContext, but it will be used for more later.
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qobject.cpp8
-rw-r--r--src/corelib/kernel/qobject_p.h12
2 files changed, 19 insertions, 1 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 638c7d1..220e132 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 31b1593..81d3aba 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -85,6 +85,13 @@ inline QObjectData::~QObjectData() {}
enum { QObjectPrivateVersion = QT_VERSION };
+class Q_CORE_EXPORT 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;