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:
|
def selected(self) -> bool:
|
||||||
return self._selected
|
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:
|
def set_selected(self, value: bool) -> None:
|
||||||
self._selected = value
|
self._selected = value
|
||||||
self.selectedChanged.emit()
|
self.selectedChanged.emit()
|
||||||
@ -1186,19 +1194,14 @@ class MapModel(QObject):
|
|||||||
)
|
)
|
||||||
return flights
|
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:
|
def reset_atos(self) -> None:
|
||||||
self._flights = self._flights_in_ato(
|
self._flights = self._flights_in_ato(
|
||||||
self.game.blue.ato, blue=True
|
self.game.blue.ato, blue=True
|
||||||
) | self._flights_in_ato(self.game.red.ato, blue=False)
|
) | self._flights_in_ato(self.game.red.ato, blue=False)
|
||||||
self.flightsChanged.emit()
|
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:
|
if selected_flight is None:
|
||||||
self._ip_zones = IpZonesJs.empty()
|
self._ip_zones = IpZonesJs.empty()
|
||||||
self._join_zones = JoinZonesJs.empty()
|
self._join_zones = JoinZonesJs.empty()
|
||||||
|
|||||||
@ -892,6 +892,19 @@ class Flight {
|
|||||||
}
|
}
|
||||||
|
|
||||||
drawFlightPlan() {
|
drawFlightPlan() {
|
||||||
|
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;
|
||||||
|
}
|
||||||
const path = [];
|
const path = [];
|
||||||
this.flightPlan.forEach((waypoint) => {
|
this.flightPlan.forEach((waypoint) => {
|
||||||
if (waypoint.includeInPath()) {
|
if (waypoint.includeInPath()) {
|
||||||
@ -906,6 +919,7 @@ class Flight {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.drawPath(path);
|
this.drawPath(path);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user