From 7e3cebb96d68d23aceaa627ad54b82ed4dcd9919 Mon Sep 17 00:00:00 2001 From: RndName Date: Sat, 19 Jun 2021 19:33:35 +0200 Subject: [PATCH] Fix purchase groups. The new class PurchaseGroup coming in with commit 9bb986c was not initiallized correctly. This causes the bug that the update function is not working when you for example open the AircraftRecruitmentMenu press "+" or "-", close the dialog and then open ArmorRecruitmentMenu. If you then want to buy or sell the update function will raise an error "Internal C++ Object Already Deleted". --- qt_ui/windows/basemenu/QRecruitBehaviour.py | 3 ++- qt_ui/windows/basemenu/airfield/QAircraftRecruitmentMenu.py | 2 +- qt_ui/windows/basemenu/ground_forces/QArmorRecruitmentMenu.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/qt_ui/windows/basemenu/QRecruitBehaviour.py b/qt_ui/windows/basemenu/QRecruitBehaviour.py index 7c6bf51c..da2f3045 100644 --- a/qt_ui/windows/basemenu/QRecruitBehaviour.py +++ b/qt_ui/windows/basemenu/QRecruitBehaviour.py @@ -76,13 +76,14 @@ class PurchaseGroup(QGroupBox): class QRecruitBehaviour: game_model: GameModel cp: ControlPoint - purchase_groups: dict[UnitType, PurchaseGroup] = {} + purchase_groups: dict[UnitType, PurchaseGroup] existing_units_labels = None maximum_units = -1 BUDGET_FORMAT = "Available Budget: ${:.2f}M" def __init__(self) -> None: self.existing_units_labels = {} + self.purchase_groups = {} self.update_available_budget() @property diff --git a/qt_ui/windows/basemenu/airfield/QAircraftRecruitmentMenu.py b/qt_ui/windows/basemenu/airfield/QAircraftRecruitmentMenu.py index f4052c2a..96fbf74e 100644 --- a/qt_ui/windows/basemenu/airfield/QAircraftRecruitmentMenu.py +++ b/qt_ui/windows/basemenu/airfield/QAircraftRecruitmentMenu.py @@ -26,7 +26,7 @@ class QAircraftRecruitmentMenu(QFrame, QRecruitBehaviour): QFrame.__init__(self) self.cp = cp self.game_model = game_model - + self.purchase_groups = {} self.bought_amount_labels = {} self.existing_units_labels = {} diff --git a/qt_ui/windows/basemenu/ground_forces/QArmorRecruitmentMenu.py b/qt_ui/windows/basemenu/ground_forces/QArmorRecruitmentMenu.py index 5c8485b2..898d1cc4 100644 --- a/qt_ui/windows/basemenu/ground_forces/QArmorRecruitmentMenu.py +++ b/qt_ui/windows/basemenu/ground_forces/QArmorRecruitmentMenu.py @@ -18,7 +18,7 @@ class QArmorRecruitmentMenu(QFrame, QRecruitBehaviour): QFrame.__init__(self) self.cp = cp self.game_model = game_model - + self.purchase_groups = {} self.bought_amount_labels = {} self.existing_units_labels = {}