Details
-
Suggestion
-
Resolution: Out of scope
-
P3: Somewhat important
-
4.4.0
-
None
Description
I had a hard time today figuring out why Qt 4.4 issues a
QObject: Do not delete object, 'unnamed'
during its event handler. In my code. I ended up patching qobject.cpp to get some more information
on the object. So here is my suggestion. At the end of QObject::~QObject you currently have:
if (d->inEventHandler) { qWarning("QObject: Do not delete object, '%s', during its event handler!", objectName().isNull() ? "unnamed" : qPrintable(objectName())); }
I would suggest to move this to the beginning of the destructor (because
here the internals are not yet cleaned up) and add a dumpObjectInfo(); so that this looks like that:
QObject::~QObject() { Q_D(QObject); if (d->wasDeleted) { #if defined(QT_DEBUG) qWarning("QObject: Double deletion detected"); #endif return; } if (d->inEventHandler) { qWarning("QObject: Do not delete object, '%s', during its event handler!", objectName().isNull() ? "unnamed" : qPrintable(objectName())); this->dumpObjectInfo(); }
This would make finding the culprit in these cases much easier, because
you get information on connected signals etc. Of course you should additionally check if debug output is desired.