This repository has been archived by the owner on Mar 5, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MainWindow.fxml: update onCloseRequest event to call handleExit()
The MainWindow does not have an event handler to handle external requests (such as the close button or through the taskbar) to close the MainWindow. This may cause the app to not close properly since MainApp#stop() is not called as the ExitAppRequestEvent is not raised. MainApp#stop() is the method used to call Platform#exit() and System#exit(int) which closes our app and all remaining open windows. Thus, if MainApp#stop() is not called, the app may continue to run even after the MainWindow is closed, causing existing HelpWindows to remain open even when the user expects the app to stop. According to the life-cycle section in the documentation on JavaFX Application[1], the app will only finish and call MainApp#stop() when the app either calls Platform#exit() or when the last window has been closed. Thus, should there be any HelpWindows still opened, the app will continue running, causing those HelpWindows to remain open. Let's add an event handler for the onCloseRequest event in the root of MainWindow.fxml. This event will call MainWindow#handleExit(), which raises an ExitAppRequestEvent, when there is an external request to close the app. EmptyMainWindowHandle does not contain a close button, thus to test if an ExitAppRequestEvent was raised, we fire a WindowEvent#WINDOW_CLOSE_REQUEST event which will trigger the onCloseRequest event. [1] JavaFx documentation for Application: https://docs.oracle.com/javafx/2/api/javafx/application/Application.html
- Loading branch information