Comment 188 for bug 236901

Revision history for this message
In , Dtownsend (dtownsend) wrote :

(In reply to comment #5)
> This is what I think is true:

Ok this was wrong. Here is what actually goes on:

mRunning is set to true when the application event loop is started and set to false after the event loop is exited, so basically true while the app is open and responding to events from the OS.

mAttemptingQuit is set to true when Quit has been called and the application is attempting to shutdown. This shutdown is asynchronous, we must tell all windows to close and then return from Quit waiting for them to do so. mAttemptingQuit remains true until the attempt to shutdown is abandoned by a new window opening.

mShuttingDown is set to true while we are in the Quit method. If we have to exit from Quit to wait for windows to close it gets set back to false. If all Quit finds that all windows are closed then it dispatches the shutdown event and mShuttingDown remains true.

The only way to stop quit-application-granted being dispatched twice in the same session (and retain sanity) would be to move it to after the point where all windows have closed. This is the same point that we dispatch quit-application already.

The alternative would be to dispatch it as it is now when we attempt to close windows, and assuming shutdown is never aborted never dispatch it again. However in that scenario I think it would be sensible to dispatch an event when shutdown is aborted and basically say that quit-application-granted might happen again after that.