summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-07-31 17:35:34 +0200
committerThiago Macieira <thiago.macieira@nokia.com>2009-08-03 13:18:13 +0200
commit128717b171f01c82e5f0fb83f5923d4f7b9cfc10 (patch)
tree5e138ede4db646436a3af071247546f820e42ed8
parent1b469ac64cf81476436009aef66009c30335a01c (diff)
Remove currentChildBeingDeleted from QObjectPrivate.
When a child is being deleted by its parent, the child should not notify the parent (of that which it already knows anyway). We did that by keeping a pointer to the child being deleted. Much simpler to simply orphan the child. Reviewed-by: Bradley T. Hughes
-rw-r--r--src/corelib/kernel/qobject.cpp29
-rw-r--r--src/corelib/kernel/qobject_p.h5
2 files changed, 13 insertions, 21 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index ab91799d11..7bf209a3b0 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -123,7 +123,7 @@ extern "C" Q_CORE_EXPORT void qt_removeObject(QObject *)
}
QObjectPrivate::QObjectPrivate(int version)
- : threadData(0), currentSender(0), currentChildBeingDeleted(0), connectionLists(0), senders(0)
+ : threadData(0), currentSender(0), declarativeData(0), connectionLists(0), senders(0)
{
if (version != QObjectPrivateVersion)
qFatal("Cannot mix incompatible Qt libraries");
@@ -1859,12 +1859,13 @@ void QObjectPrivate::deleteChildren()
// don't use qDeleteAll as the destructor of the child might
// delete siblings
for (int i = 0; i < children.count(); ++i) {
- currentChildBeingDeleted = children.at(i);
+ QObject *child = children.at(i);
children[i] = 0;
- delete currentChildBeingDeleted;
+ if (child)
+ child->d_func()->parent = 0;
+ delete child;
}
children.clear();
- currentChildBeingDeleted = 0;
wasDeleted = reallyWasDeleted;
}
@@ -1875,20 +1876,14 @@ void QObjectPrivate::setParent_helper(QObject *o)
return;
if (parent) {
QObjectPrivate *parentD = parent->d_func();
- if (parentD->wasDeleted && wasDeleted
- && parentD->currentChildBeingDeleted == q) {
- // don't do anything since QObjectPrivate::deleteChildren() already
- // cleared our entry in parentD->children.
+ const int index = parentD->children.indexOf(q);
+ if (parentD->wasDeleted) {
+ parentD->children[index] = 0;
} else {
- const int index = parentD->children.indexOf(q);
- if (parentD->wasDeleted) {
- parentD->children[index] = 0;
- } else {
- parentD->children.removeAt(index);
- if (sendChildEvents && parentD->receiveChildEvents) {
- QChildEvent e(QEvent::ChildRemoved, q);
- QCoreApplication::sendEvent(parent, &e);
- }
+ parentD->children.removeAt(index);
+ if (sendChildEvents && parentD->receiveChildEvents) {
+ QChildEvent e(QEvent::ChildRemoved, q);
+ QCoreApplication::sendEvent(parent, &e);
}
}
}
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index e908753b66..0b41c9afa1 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -125,10 +125,7 @@ public:
// object currently activating the object
Sender *currentSender;
- union {
- QObject *currentChildBeingDeleted;
- QDeclarativeData *declarativeData;
- };
+ QDeclarativeData *declarativeData;
bool isSender(const QObject *receiver, const char *signal) const;
QObjectList receiverList(const char *signal) const;