Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HelpWindow: modify HelpWindow#show() to use Stage#show()
opened by typing help in the command box. For instance, the command box does not display the result message of subsequent commands. However, this does not occur when opening the help window by pressing F1 or pressing help from the help menu. This occurs due to a combination of using the default Dispatcher used by the Guava EventBus system, Dispatcher#perThreadDispatchQueue(), along with calling Stage#showAndWait(). Calling Stage#showAndWait(), starts a nested event loop to handle subsequent JavaFX events. However, the default Dispatcher used by the EventBus does not allow nested callback invocations, and instead queues them to be invoked after the current invoked callback, the MainWindow#handleShowHelpEvent() completes. As such, EventBus events are queued up in the meantime resulting in the subscribers of these events having to wait until the nested event loop is terminated (i.e. when the callback completes, after the help window is closed.) And so, the UI components will only receive these events and therefore update after the help window is closed. However, in the case of pressing F1 or pressing help from the help menu, MainWindow#handleHelp() is called immediately without posting the MainWindow#handleShowHelpEvent(). Since this event never enters the EventBus's queue, the nested event loop started by Stage#showAndWait() does not block it and subsequent EventBus events get dispatched as usual. Let's replace Stage#showAndWait() with Stage#show(), so that there will be no entering of a nested loop and hence no blockage of the Guava EventBus system. Likewise, this could be fixed by using the Dispatcher#immediate() dispatcher instead of the default dispatcher used by the Guava EventBus system. However, replacing Stage#showAndWait() with Stage#show() is more suitable in this case as it is sufficient to show the help window instead of starting a nested event loop to handle subsequent JavaFX events while waiting for the help window to be closed. JavaFX documentation for Stage: https://docs.oracle.com/javase/8/javafx/api/javafx/stage/Stage.html Code and documentation for the Guava Dispatcher: https://github.com/google/guava/blob/master/guava/src/com/google/common/eventbus/Dispatcher.java More information on the Guava EventBus system: https://github.com/google/guava/wiki/EventBusExplained
- Loading branch information