Details
-
User Story
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
None
-
None
Description
Events should only have the spontaneous flag set if they original from outside the application itself. Synthesised events should not have the flag set, so that applications can distinguish between them (and so that a test framework can replay only spontaneous events).
QEvent::Quit might be generated when QApplication::quit() is called by the application (e.g. in response to activating the File->Quit action or the last window getting closed by the user). On macOS, a user can also explicitly quit the application through the tray icon's context menu.
In the former cases, the Quit event is synthesised in response to the application handling the event; here, the spontaneous flag should not be set. In the latter case, the Quit event is spontaneous.
Note that this is only a problem with QGuiApplication and QApplication, as their private classes override QCoreApplication::quit() to go through the platform integration (which then by default pretends that the window system requested the application to quit; the Cocoa implementation goes through AppKit's NSApp::terminate). QCoreApplication::quit() just synthesises and posts/sends a QEvent::Quit to itself.