Usually, sending a WM_QUIT message to a QApplication triggers the QCoreApplication::aboutToQuit() signal, e.g. when ending the application via Windows's Task Manager, or using "taskkill /PID <pid>".

We discovered that no aboutToQuit() signal is emitted when a QApplication without windows receives a WM_QUIT:

    #include <QApplication>
    #include <QDebug>
    #include <QWidget>

    int main(int argc, char *argv[]) {
      QApplication app(argc, argv);

      QApplication::connect(&app, &QApplication::aboutToQuit, []() {
        qDebug() << "QApplication::aboutToQuit";
      });

      // Commenting those lines will not trigger aboutToQuit() when
      // the application is closed via Task Manager:
      QWidget w;
      w.show();

      return app.exec();
    }

Our application supports a text-only variant, where the GUI is disabled. We're basically doing it like that, and wondered why our shutdown code was not called when the application was quit via the Task Manager.

Is there anything that needs to be done to get consistent behavior?

_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to