summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-08-04 16:01:33 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2009-08-04 16:01:33 (GMT)
commit83ff02450ea74468fec441e632ddc2cfda2b251c (patch)
treecf830305b22ab065c8016321158742af788d64b8
parent31edb4d5a63b9b3c28cce1c4ca6eb99f62a09759 (diff)
downloadQt-83ff02450ea74468fec441e632ddc2cfda2b251c.zip
Qt-83ff02450ea74468fec441e632ddc2cfda2b251c.tar.gz
Qt-83ff02450ea74468fec441e632ddc2cfda2b251c.tar.bz2
Revert "Remove currentChildBeingDeleted from QObjectPrivate."
This reverts commit 128717b171f01c82e5f0fb83f5923d4f7b9cfc10. The change broke Alien because QWidget no longer has the native window handle in its own private. It needs to access the top-level window (or the one with the native handle) in order to perform some operations. The problem is that it needs to do that in the destructor. And we cleared the parent before the destructor was run. Technically speaking, reverting is the correct thing to do, since the parent *still* exists when the child is deleted.
-rw-r--r--src/corelib/kernel/qobject.cpp29
-rw-r--r--src/corelib/kernel/qobject_p.h1
2 files changed, 18 insertions, 12 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 1938012..0801418 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -126,7 +126,7 @@ QObjectData::~QObjectData() {}
QObjectDeletionNotification::~QObjectDeletionNotification() {}
QObjectPrivate::QObjectPrivate(int version)
- : threadData(0), connectionLists(0), senders(0), currentSender(0), deletionNotification(0), objectGuards(0)
+ : threadData(0), connectionLists(0), senders(0), currentSender(0), currentChildBeingDeleted(0), deletionNotification(0), objectGuards(0)
{
if (version != QObjectPrivateVersion)
qFatal("Cannot mix incompatible Qt libraries");
@@ -1855,13 +1855,12 @@ void QObjectPrivate::deleteChildren()
// don't use qDeleteAll as the destructor of the child might
// delete siblings
for (int i = 0; i < children.count(); ++i) {
- QObject *child = children.at(i);
+ currentChildBeingDeleted = children.at(i);
children[i] = 0;
- if (child)
- child->d_func()->parent = 0;
- delete child;
+ delete currentChildBeingDeleted;
}
children.clear();
+ currentChildBeingDeleted = 0;
wasDeleted = reallyWasDeleted;
}
@@ -1872,14 +1871,20 @@ void QObjectPrivate::setParent_helper(QObject *o)
return;
if (parent) {
QObjectPrivate *parentD = parent->d_func();
- const int index = parentD->children.indexOf(q);
- if (parentD->wasDeleted) {
- parentD->children[index] = 0;
+ if (parentD->wasDeleted && wasDeleted
+ && parentD->currentChildBeingDeleted == q) {
+ // don't do anything since QObjectPrivate::deleteChildren() already
+ // cleared our entry in parentD->children.
} else {
- parentD->children.removeAt(index);
- if (sendChildEvents && parentD->receiveChildEvents) {
- QChildEvent e(QEvent::ChildRemoved, q);
- QCoreApplication::sendEvent(parent, &e);
+ 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);
+ }
}
}
}
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index 52b4658..a7f3a5a 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -182,6 +182,7 @@ public:
#endif
QList<QPointer<QObject> > eventFilters;
+ QObject *currentChildBeingDeleted;
// these objects are all used to indicate that a QObject was deleted
// plus QPointer, which keeps a separate list