Details
-
Bug
-
Resolution: Fixed
-
P4: Low
-
5.14.1
-
None
Description
In the following snippet ~MyObject dtor is never run.
#include <QDebug> #include <QCoreApplication> class MyObject : public QObject { public: MyObject() { qDebug() << "CTOR" << this; } ~MyObject() { qDebug() << "DTOR" << this; } bool event(QEvent *ev) override { if (ev->type() == QEvent::User) { qDebug() << "Got a user event, will deleteLater()"; deleteLater(); } return QObject::event(ev); } }; int main(int a, char **b) { QCoreApplication app(a, b); auto obj = new MyObject(); QEvent ev(QEvent::User); QCoreApplication::sendEvent(obj, &ev); return app.exec(); } // Output: $ CTOR QObject(0x56427a6211b0) $ Got a user event, will deleteLater()