Details
-
Bug
-
Resolution: Done
-
P4: Low
-
4.8.x, 5.4.0, 5.6.0
-
Windows/all
-
c5d49725779292a04fed599eb7f508d334ffc5c3 (qtbase/dev, 12.2.2016, 5.7.0)
Description
As described at https://forum.qt.io/topic/15042/deletelater-from-within-activex-event-handler :
- Take the webbrowser example.
- Add a new class:
class QExample : public QObject { public: bool event(QEvent* e) override { if (e->type() == QEvent::DeferredDelete) QMessageBox::information(0, "1", "DeferredDelete"); return QObject::event(e); } };
- Add it to MainWindow:
class MainWindow : public QMainWindow, public Ui::MainWindow { ... QExample* ex; };
- Create it:
MainWindow::MainWindow() { ex = new QExample; ... }
- Request its deletion:
void MainWindow::on_WebBrowser_NavigateComplete(const QString &url) { ex->deleteLater(); ... }
The example object is expected to be deleted when the execution returns to the event loop, but it only happens when the browser is closed.
A little background. I have an application that can be run both as a standalone executable and an ActiveX server. In the first mode, all is fine, but deleteLater()s don't properly work in the latter, the deferred-deleted objects basically leak during the application lifetime.