mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-11 08:07:24 -05:00
Wrap setAliases() in Platform.runLater() (#885)
Fixes issue #884 (see issue for more info). AliasItemEditor.save() modifies objects that are observed by the TableView's underlying SortedList. Thus, the TableView's selection can change by calling save(), which means the ListChangeListener can be fired. This is a problem for two reasons. 1. The alert dialogue that prompts the user to save a modified alias will show when the user presses the "save" button, because saving modifies the selected alias and causes the list to update. 2. setAliases() calls Alert.showAndWait(). From the JavaDoc: "It must not be called during animation or layout processing." This statement is likely there because it can cause issues like the one here: TableView's layout processing (and the list updating) is paused and the list is further modified (by calling save()). Thus, when the processing is resumed the list is in a different and unexpected state. Calling setAliases() from Platform.runLater() will allow the SortedList, TableView, and any other involved objects to finish processing changes before more modifications are made. Additionally, it allows save(), when called by pressing the save button, to complete and set the modifiedProperty to false, so setAliases() does not display an additional save prompt.
This commit is contained in:
@@ -422,7 +422,7 @@ public class AliasConfigurationEditor extends SplitPane
|
||||
mAliasTableView.setItems(getAliasSortedList());
|
||||
mAliasTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
||||
mAliasTableView.getSelectionModel().getSelectedItems().addListener((ListChangeListener<Alias>)c -> {
|
||||
setAliases(mAliasTableView.getSelectionModel().getSelectedItems());
|
||||
Platform.runLater(() -> setAliases(mAliasTableView.getSelectionModel().getSelectedItems()));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user