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 has no specified event handler when there are external requests to close the MainWindow, such as the close button or through the taskbar. This may cause the app to not close properly since it will not raise an ExitAppRequestEvent, in turn MainApp#stop() is not called. MainApp#stop() is the method used to call Platform#exit() and System#exit(int) which stops our app and closes 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() when raised by an external request to close the app. MainWindowHandleUnit does not contain a close button, thus we fire a WindowEvent#WINDOW_CLOSE_REQUEST event which simulates an external request to close the MainWindow for testing if an ExitAppRequestEvent was raised. [1] JavaFx documentation for Application: https://docs.oracle.com/javafx/2/api/javafx/application/Application.html
- Loading branch information