RaceController/info table now makes a copy of the boat list, to avoid race conditions.
#story[1095]
This commit is contained in:
@@ -208,9 +208,15 @@ public class RaceController extends Controller {
|
|||||||
public void initialiseInfoTable(VisualiserRaceEvent race) {
|
public void initialiseInfoTable(VisualiserRaceEvent race) {
|
||||||
|
|
||||||
//Copy list of boats.
|
//Copy list of boats.
|
||||||
SortedList<VisualiserBoat> sortedBoats = new SortedList<>(race.getVisualiserRaceState().getBoats());
|
ObservableList<VisualiserBoat> boats = FXCollections.observableArrayList(race.getVisualiserRaceState().getBoats());
|
||||||
|
SortedList<VisualiserBoat> sortedBoats = new SortedList<>(boats);
|
||||||
sortedBoats.comparatorProperty().bind(boatInfoTable.comparatorProperty());
|
sortedBoats.comparatorProperty().bind(boatInfoTable.comparatorProperty());
|
||||||
|
|
||||||
|
//Update copy when original changes.
|
||||||
|
race.getVisualiserRaceState().getBoats().addListener((ListChangeListener.Change<? extends VisualiserBoat> c) -> Platform.runLater(() -> {
|
||||||
|
boats.setAll(race.getVisualiserRaceState().getBoats());
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
//Set up table.
|
//Set up table.
|
||||||
boatInfoTable.setItems(sortedBoats);
|
boatInfoTable.setItems(sortedBoats);
|
||||||
|
|||||||
@@ -183,10 +183,7 @@ public class VisualiserRaceState extends RaceState {
|
|||||||
|
|
||||||
boat.setCurrentLeg(getLegs().get(0));
|
boat.setCurrentLeg(getLegs().get(0));
|
||||||
|
|
||||||
Platform.runLater(() -> {
|
|
||||||
existingBoats.add(boat);
|
existingBoats.add(boat);
|
||||||
setPlayerBoat();
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user