mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Prevent drawing flights that are being deleted.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1720
This commit is contained in:
parent
8c2e25339f
commit
bc819d59f4
@ -606,6 +606,14 @@ class FlightJs(QObject):
|
||||
def selected(self) -> bool:
|
||||
return self._selected
|
||||
|
||||
@Slot(result=bool)
|
||||
def flightIsInAto(self) -> bool:
|
||||
if self.flight.package not in self.flight.squadron.coalition.ato.packages:
|
||||
return False
|
||||
if self.flight not in self.flight.package.flights:
|
||||
return False
|
||||
return True
|
||||
|
||||
def set_selected(self, value: bool) -> None:
|
||||
self._selected = value
|
||||
self.selectedChanged.emit()
|
||||
@ -1186,19 +1194,14 @@ class MapModel(QObject):
|
||||
)
|
||||
return flights
|
||||
|
||||
def _get_selected_flight(self) -> Optional[Flight]:
|
||||
for p_idx, package in enumerate(self.game.blue.ato.packages):
|
||||
for f_idx, flight in enumerate(package.flights):
|
||||
if (p_idx, f_idx) == self._selected_flight_index:
|
||||
return flight
|
||||
return None
|
||||
|
||||
def reset_atos(self) -> None:
|
||||
self._flights = self._flights_in_ato(
|
||||
self.game.blue.ato, blue=True
|
||||
) | self._flights_in_ato(self.game.red.ato, blue=False)
|
||||
self.flightsChanged.emit()
|
||||
selected_flight = self._get_selected_flight()
|
||||
selected_flight = None
|
||||
if self._selected_flight is not None:
|
||||
selected_flight = self._selected_flight.flight
|
||||
if selected_flight is None:
|
||||
self._ip_zones = IpZonesJs.empty()
|
||||
self._join_zones = JoinZonesJs.empty()
|
||||
|
||||
@ -892,20 +892,34 @@ class Flight {
|
||||
}
|
||||
|
||||
drawFlightPlan() {
|
||||
const path = [];
|
||||
this.flightPlan.forEach((waypoint) => {
|
||||
if (waypoint.includeInPath()) {
|
||||
path.push(waypoint.position());
|
||||
this.flight.flightIsInAto().then((inAto) => {
|
||||
if (!inAto) {
|
||||
// HACK: The signal to redraw the ATO following package/flight deletion
|
||||
// and the signal to change flight/package selection due to UI selection
|
||||
// change come in an arbitrary order. If redraw signal comes first the UI
|
||||
// will clear the map and redraw, but then when the UI updates selection
|
||||
// away from the (now deleted) flight/package it calls deselect, which
|
||||
// redraws the deleted flight plan in its deselected state.
|
||||
//
|
||||
// Avoid this by checking that the flight is still in the coalition's ATO
|
||||
// before drawing.
|
||||
return;
|
||||
}
|
||||
if (this.shouldMark(waypoint)) {
|
||||
waypoint.marker
|
||||
.addTo(selectedFlightPlansLayer)
|
||||
.addTo(this.flightPlanLayer())
|
||||
.addTo(allFlightPlansLayer);
|
||||
}
|
||||
});
|
||||
const path = [];
|
||||
this.flightPlan.forEach((waypoint) => {
|
||||
if (waypoint.includeInPath()) {
|
||||
path.push(waypoint.position());
|
||||
}
|
||||
if (this.shouldMark(waypoint)) {
|
||||
waypoint.marker
|
||||
.addTo(selectedFlightPlansLayer)
|
||||
.addTo(this.flightPlanLayer())
|
||||
.addTo(allFlightPlansLayer);
|
||||
}
|
||||
});
|
||||
|
||||
this.drawPath(path);
|
||||
this.drawPath(path);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user