App quit sequence: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(Update to reflect current sequence and fixes) |
||
Line 4: | Line 4: | ||
# Notify observers of quit-application-requested. Observers can abort the quit by setting the nsISupportsPRBool passed in the subject to true. | # Notify observers of quit-application-requested. Observers can abort the quit by setting the nsISupportsPRBool passed in the subject to true. | ||
# If the quit isn't aborted at this point, observers of quit-application-granted are notified. | # If the quit isn't aborted at this point, observers of quit-application-granted are notified. (Gecko 1.8.1 and older) | ||
# The window mediator service is then used to enumerate through all windows. If the window has a function named tryToClose defined, it is called. If tryToClose returns false, the shutdown is aborted at this point. If not, the window is closed and the next window is checked for tryToClose and so on. | # The window mediator service is then used to enumerate through all windows. If the window has a function named tryToClose defined, it is called. If tryToClose returns false, the shutdown is aborted at this point. If not, the window is closed and the next window is checked for tryToClose and so on. (Removed in Gecko 1.9 by {{bug|386002}}) | ||
# quit in the app startup service is called, which then.. | # quit in the app startup service is called, which then.. | ||
## Notifies observers of quit-application-granted. (Gecko 1.9+) | |||
## Try to close every window. If this doesn't work out, the quit is aborted in the hopes that the last window will close soon. | ## Try to close every window. If this doesn't work out, the quit is aborted in the hopes that the last window will close soon. | ||
## Observers of quit-application are notified. | ## Observers of quit-application are notified. | ||
Line 12: | Line 13: | ||
# The app can quit some time after the function returns. | # The app can quit some time after the function returns. | ||
This sequence is wrapped up in | This sequence is wrapped up in toolkit/content/globalOverlay.js. | ||
= Things to do to improve this = | = Things to do to improve this = | ||
<strike> | |||
* Eliminate tryToClose. tryToClose has problems: | * Eliminate tryToClose. tryToClose has problems: | ||
** It's arbitrary and not defined in an interface anywhere. | ** It's arbitrary and not defined in an interface anywhere. | ||
** It's called after quit-application-granted. | ** It's called after quit-application-granted. | ||
** It always closes the window after tryToClose returns true, which is not always desirable. | ** It always closes the window after tryToClose returns true, which is not always desirable. | ||
** Applications can implement this properly just by registering an observer for quit-application-requested and enumerating through windows, if needed. Firefox doesn't need this anymore. | ** Applications can implement this properly just by registering an observer for quit-application-requested and enumerating through windows, if needed. Firefox doesn't need this anymore.</strike> Fixed in {{bug|386002}} for Gecko 1.9 | ||
* Put the quit-application-granted notification into the quit call in app startup. | <strike> | ||
* Put the quit-application-granted notification into the quit call in app startup.</strike> Fixed in {{bug|386310}} for Gecko 1.9 | |||
* Wrap the quit-application-requested into a function that just returns true/false. | * Wrap the quit-application-requested into a function that just returns true/false. |
Revision as of 23:41, 28 January 2008
Current quit sequence
Right now, there are a few steps required for quitting a toolkit app:
- Notify observers of quit-application-requested. Observers can abort the quit by setting the nsISupportsPRBool passed in the subject to true.
- If the quit isn't aborted at this point, observers of quit-application-granted are notified. (Gecko 1.8.1 and older)
- The window mediator service is then used to enumerate through all windows. If the window has a function named tryToClose defined, it is called. If tryToClose returns false, the shutdown is aborted at this point. If not, the window is closed and the next window is checked for tryToClose and so on. (Removed in Gecko 1.9 by bug 386002)
- quit in the app startup service is called, which then..
- Notifies observers of quit-application-granted. (Gecko 1.9+)
- Try to close every window. If this doesn't work out, the quit is aborted in the hopes that the last window will close soon.
- Observers of quit-application are notified.
- Dispatch exit event.
- The app can quit some time after the function returns.
This sequence is wrapped up in toolkit/content/globalOverlay.js.
Things to do to improve this
Eliminate tryToClose. tryToClose has problems:- It's arbitrary and not defined in an interface anywhere.
- It's called after quit-application-granted.
- It always closes the window after tryToClose returns true, which is not always desirable.
Applications can implement this properly just by registering an observer for quit-application-requested and enumerating through windows, if needed. Firefox doesn't need this anymore.Fixed in bug 386002 for Gecko 1.9
Put the quit-application-granted notification into the quit call in app startup.Fixed in bug 386310 for Gecko 1.9- Wrap the quit-application-requested into a function that just returns true/false.