Fix Exception: 'DeadFlightPlan' object has no attribute 'targets'

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2247
This commit is contained in:
Raffson 2022-06-12 22:34:43 +02:00 committed by GitHub
parent 70e5c578ae
commit c5ff8777be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -98,9 +98,8 @@ class QFlightWaypointTab(QFrame):
def on_delete_waypoint(self):
waypoints = []
for (
selected_row
) in self.flight_waypoint_list.selectionModel().selectedIndexes():
selection = self.flight_waypoint_list.selectionModel()
for selected_row in selection.selectedIndexes():
if selected_row.row() > 0:
waypoints.append(self.flight.flight_plan.waypoints[selected_row.row()])
for waypoint in waypoints:
@ -113,9 +112,10 @@ class QFlightWaypointTab(QFrame):
# If the waypoint is a target waypoint and is not the last target
# waypoint, we don't need to degrade.
if isinstance(self.flight.flight_plan, FormationAttackFlightPlan):
is_target = waypoint in self.flight.flight_plan.targets
if is_target and len(self.flight.flight_plan.targets) > 1:
self.flight.flight_plan.targets.remove(waypoint)
is_target = waypoint in self.flight.flight_plan.target_area_waypoint.targets
count = len(self.flight.flight_plan.target_area_waypoint.targets)
if is_target and count > 1:
self.flight.flight_plan.target_area_waypoint.targets.remove(waypoint)
return
self.degrade_to_custom_flight_plan()