Details
-
Bug
-
Resolution: Done
-
Not Evaluated
-
5.6.0
-
None
Description
Reproducible with the following example. When running this example a widget is shown and an object is created when you click inside this widget. When the applications state changes (for example by switching to another app) the object is scheduled for deletion. Although the application event loop is entered again the object never get's destructed during the runtime of the main event loop.
I started to debug this issue and it seems that the allowDeferredDelete requirement inside QCoreApplicationPrivate::sendPostedEvents is never fulfilled.
main.cpp
#include <QApplication> #include <QDebug> #include <QWidget> class Object : public QObject { public: ~Object(){ qDebug() << "object deleted" << (quint64)this; } }; Object *object = 0; class Widget : public QWidget { protected: void mousePressEvent(QMouseEvent *) override { if (!object) { object = new Object(); qDebug() << "new object" << (quint64)object; } } }; int main(int argc, char *argv[]) { QApplication a(argc, argv); Widget w; w.show(); QObject::connect(qApp, &QApplication::applicationStateChanged, [](){ if (object) { qDebug() << "delete object later" << (quint64)object; object->deleteLater(); object = 0; } }); return a.exec(); }
Attachments
Issue Links
- relates to
-
QTCREATORBUG-15882 Tooltip remains on top of other windows when switching away from Creator
- Closed