From 82281e24771ebe3819d10071124dbd3d6a11c44c Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sun, 30 May 2021 15:46:54 -0700 Subject: [PATCH] Fix inventory handling when adjusting flight size. We need to resize the flight before attempting to claim the aircraft, or we'll reclaim the original number of aircraft rather than the new size. --- qt_ui/windows/mission/flight/settings/QFlightSlotEditor.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/qt_ui/windows/mission/flight/settings/QFlightSlotEditor.py b/qt_ui/windows/mission/flight/settings/QFlightSlotEditor.py index d3465cb5..25668aba 100644 --- a/qt_ui/windows/mission/flight/settings/QFlightSlotEditor.py +++ b/qt_ui/windows/mission/flight/settings/QFlightSlotEditor.py @@ -202,8 +202,10 @@ class QFlightSlotEditor(QGroupBox): self.setLayout(layout) def _changed_aircraft_count(self): - self.game.aircraft_inventory.return_from_flight(self.flight) + old_count = self.flight.count new_count = int(self.aircraft_count_spinner.value()) + self.game.aircraft_inventory.return_from_flight(self.flight) + self.flight.resize(new_count) try: self.game.aircraft_inventory.claim_for_flight(self.flight) except ValueError: @@ -217,7 +219,6 @@ class QFlightSlotEditor(QGroupBox): f"{available} {self.flight.unit_type} remaining" ) self.game.aircraft_inventory.claim_for_flight(self.flight) + self.flight.resize(old_count) return - - self.flight.resize(new_count) self.roster_editor.resize(new_count)