diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-09-16 10:14:40 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-09-16 13:13:04 (GMT) |
commit | 64017d5d8a431c100ae190567cfd815dce02b334 (patch) | |
tree | f16ccb54a612d4e8b9b3910a438e2cf38c3707f7 | |
parent | fc2ae0267e6ecbe9a641a44b953f6363beedb501 (diff) | |
download | Qt-64017d5d8a431c100ae190567cfd815dce02b334.zip Qt-64017d5d8a431c100ae190567cfd815dce02b334.tar.gz Qt-64017d5d8a431c100ae190567cfd815dce02b334.tar.bz2 |
Move QGuard to the ExtraData
not every QObject need a pointer to the QGuard while none of them will
usually use it (it is private API)
Reviewed-by: Thiago
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 18 | ||||
-rw-r--r-- | src/corelib/kernel/qobject_p.h | 12 |
2 files changed, 15 insertions, 15 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index b4e3959..a8120cf 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -129,7 +129,7 @@ QObjectData::~QObjectData() {} QDeclarativeData::~QDeclarativeData() {} QObjectPrivate::QObjectPrivate(int version) - : threadData(0), connectionLists(0), senders(0), currentSender(0), currentChildBeingDeleted(0), declarativeData(0), objectGuards(0) + : threadData(0), connectionLists(0), senders(0), currentSender(0), currentChildBeingDeleted(0) { if (version != QObjectPrivateVersion) qFatal("Cannot mix incompatible Qt libraries"); @@ -496,18 +496,14 @@ void QMetaObject::changeGuard(QObject **ptr, QObject *o) void QObjectPrivate::clearGuards(QObject *object) { QObjectPrivate *priv = QObjectPrivate::get(object); - QGuard<QObject> *guard = priv->objectGuards; + QGuard<QObject> *guard = priv->extraData ? priv->extraData->objectGuards : 0; while (guard) { - guard->o = 0; + QGuard<QObject> *g = guard; guard = guard->next; - } - while (priv->objectGuards) { - guard = priv->objectGuards; - guard->prev = 0; - if (guard->next) guard->next->prev = &priv->objectGuards; - priv->objectGuards = guard->next; - guard->next = 0; - guard->objectDestroyed(object); + g->o = 0; + g->prev = 0; + g->next = 0; + g->objectDestroyed(object); } if (!priv->hasGuards) diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index e7d824b..eb8035c 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -99,11 +99,13 @@ class Q_CORE_EXPORT QObjectPrivate : public QObjectData public: struct ExtraData { + ExtraData() : objectGuards(0) {} #ifndef QT_NO_USERDATA QVector<QObjectUserData *> userData; #endif QList<QByteArray> propertyNames; QList<QVariant> propertyValues; + QGuard<QObject> *objectGuards; //linked list handle of QGuards }; struct Connection @@ -197,7 +199,6 @@ public: // these objects are all used to indicate that a QObject was deleted // plus QPointer, which keeps a separate list QDeclarativeData *declarativeData; - QGuard<QObject> *objectGuards; QAtomicPointer<QtSharedPointer::ExternalRefCountData> sharedRefcount; int *deleteWatch; }; @@ -211,9 +212,12 @@ inline void q_guard_addGuard(QGuard<QObject> *g) return; } - g->next = p->objectGuards; - p->objectGuards = g; - g->prev = &p->objectGuards; + if (!p->extraData) + p->extraData = new QObjectPrivate::ExtraData; + + g->next = p->extraData->objectGuards; + p->extraData->objectGuards = g; + g->prev = &p->extraData->objectGuards; if (g->next) g->next->prev = &g->next; } |