summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qobject.cpp2
-rw-r--r--src/widgets/kernel/qwidget.cpp18
2 files changed, 19 insertions, 1 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 0d97266f4f..9d0854f3a9 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -766,7 +766,7 @@ QObject::~QObject()
delete sharedRefcount;
}
- if (d->isSignalConnected(0)) {
+ if (!d->isWidget && d->isSignalConnected(0)) {
QT_TRY {
emit destroyed(this);
} QT_CATCH(...) {
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 83dc406e17..d05f53697a 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -1429,11 +1429,29 @@ QWidget::~QWidget()
delete d->needsFlush;
d->needsFlush = 0;
+ // The next 20 lines are duplicated from QObject, but required here
+ // since QWidget deletes is children itself
+ bool blocked = d->blockSig;
+ d->blockSig = 0; // unblock signals so we always emit destroyed()
+
+ if (d->isSignalConnected(0)) {
+ QT_TRY {
+ emit destroyed(this);
+ } QT_CATCH(...) {
+ // all the signal/slots connections are still in place - if we don't
+ // quit now, we will crash pretty soon.
+ qWarning("Detected an unexpected exception in ~QWidget while emitting destroyed().");
+ QT_RETHROW;
+ }
+ }
+
if (d->declarativeData) {
QAbstractDeclarativeData::destroyed(d->declarativeData, this);
d->declarativeData = 0; // don't activate again in ~QObject
}
+ d->blockSig = blocked;
+
#ifdef Q_WS_MAC
// QCocoaView holds a pointer back to this widget. Clear it now
// to make sure it's not followed later on. The lifetime of the