Fixes : Missing weapons names would cause flight edition window to crash while setting up default loadout UI, preventing the user from editing flights.

This commit is contained in:
Khopa 2021-02-26 23:30:23 +01:00
parent 60af2ad0a4
commit 58d5aa9944

View File

@ -64,6 +64,7 @@ class QPylonEditor(QComboBox):
if pylon_default_weapon is not None:
if self.game.settings.restrict_weapons_by_date:
orig_weapon = Weapon.from_clsid(pylon_default_weapon)
if orig_weapon is not None:
if not orig_weapon.available_on(self.game.date):
for fallback in orig_weapon.fallbacks:
if historical_weapon is None:
@ -75,12 +76,14 @@ class QPylonEditor(QComboBox):
else:
historical_weapon = orig_weapon
if historical_weapon is not None:
self.setCurrentText(
weapons_data.weapon_ids.get(historical_weapon.cls_id).get(
"name"
)
)
self.setCurrentText(historical_weapon.cls_id)
else:
self.setCurrentText(pylon_default_weapon)
else:
weapon = weapons_data.weapon_ids.get(pylon_default_weapon)
if weapon is not None:
self.setCurrentText(
weapons_data.weapon_ids.get(pylon_default_weapon).get("name")
)
else:
self.setCurrentText(pylon_default_weapon)