Skip to content

Commit

Permalink
Fix disappearing aircraft when deleting packages.
Browse files Browse the repository at this point in the history
There are a few different code paths for deleting packages depending on
the state of the package, and two of them were deleting items from a
list they were iterating over without first making a copy, causing each
iteration of the loop to skip over a flight, making it still used since
the flight was never deleted, but unreachable since the package that
owned it was deleted.

This only happened when the package was canceled in its draft state
(the user clicked the X without ever saving the package), or if the user
canceled a package mid fast forward (the controls for which aren't even
visible to users) while only a portion of the package was active. In
both cases, only even numbered flights were lost.

There's a better fix lurking in here somewhere but the interaction with
the Qt model complicates it. Fortunately that mess would be cleaned up
automatically by moving this dialog into React, which we'll do some day.

Fixes #3257.
Fixes #3258.
DanAlbert committed Dec 1, 2023
1 parent b99eb49 commit 28d959b
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ Saves from 9.x are not compatible with 10.0.0.

## Fixes

* **[Flight Planning]** Aircraft from even numbered flights will no longer become inaccessible when canceling a draft package.
* **[UI]** Flight members in the loadout menu are now numbered starting from 1 instead of 0.

# 9.0.0
2 changes: 1 addition & 1 deletion qt_ui/models.py
Original file line number Diff line number Diff line change
@@ -288,7 +288,7 @@ def cancel_or_abort_package(self, package: Package) -> None:
return

package_model = self.find_matching_package_model(package)
for flight in package.flights:
for flight in list(package.flights):
if flight.state.cancelable:
package_model.delete_flight(flight)
events.delete_flight(flight)
2 changes: 1 addition & 1 deletion qt_ui/windows/mission/QPackageDialog.py
Original file line number Diff line number Diff line change
@@ -261,7 +261,7 @@ def on_save(self) -> None:

def on_cancel(self) -> None:
super().on_cancel()
for flight in self.package_model.package.flights:
for flight in list(self.package_model.package.flights):
self.package_model.cancel_or_abort_flight(flight)


0 comments on commit 28d959b

Please sign in to comment.