mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Fix exceptions when no aircraft are selected.
This commonly happens during reset of the UI, but also happens when the player is out of aircraft.
This commit is contained in:
parent
29b4b62a44
commit
e09f53da8f
@ -1,5 +1,5 @@
|
||||
"""Combo box for selecting a departure airfield."""
|
||||
from typing import Iterable
|
||||
from typing import Iterable, Optional
|
||||
|
||||
from PySide2.QtWidgets import QComboBox
|
||||
from dcs.unittype import FlyingType
|
||||
@ -18,7 +18,7 @@ class QArrivalAirfieldSelector(QComboBox):
|
||||
def __init__(
|
||||
self,
|
||||
destinations: Iterable[ControlPoint],
|
||||
aircraft: AircraftType,
|
||||
aircraft: Optional[AircraftType],
|
||||
optional_text: str,
|
||||
) -> None:
|
||||
super().__init__()
|
||||
@ -28,7 +28,7 @@ class QArrivalAirfieldSelector(QComboBox):
|
||||
self.rebuild_selector()
|
||||
self.setCurrentIndex(0)
|
||||
|
||||
def change_aircraft(self, aircraft: FlyingType) -> None:
|
||||
def change_aircraft(self, aircraft: Optional[FlyingType]) -> None:
|
||||
if self.aircraft == aircraft:
|
||||
return
|
||||
self.aircraft = aircraft
|
||||
@ -36,6 +36,8 @@ class QArrivalAirfieldSelector(QComboBox):
|
||||
|
||||
def rebuild_selector(self) -> None:
|
||||
self.clear()
|
||||
if self.aircraft is None:
|
||||
return
|
||||
for destination in self.destinations:
|
||||
if destination.can_operate(self.aircraft):
|
||||
self.addItem(destination.name, destination)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
"""Combo box for selecting a departure airfield."""
|
||||
from typing import Iterable
|
||||
from typing import Iterable, Optional
|
||||
|
||||
from PySide2.QtCore import Signal
|
||||
from PySide2.QtWidgets import QComboBox
|
||||
@ -23,7 +23,7 @@ class QOriginAirfieldSelector(QComboBox):
|
||||
self,
|
||||
global_inventory: GlobalAircraftInventory,
|
||||
origins: Iterable[ControlPoint],
|
||||
aircraft: AircraftType,
|
||||
aircraft: Optional[AircraftType],
|
||||
) -> None:
|
||||
super().__init__()
|
||||
self.global_inventory = global_inventory
|
||||
@ -33,7 +33,7 @@ class QOriginAirfieldSelector(QComboBox):
|
||||
self.currentIndexChanged.connect(self.index_changed)
|
||||
self.setSizeAdjustPolicy(self.AdjustToContents)
|
||||
|
||||
def change_aircraft(self, aircraft: FlyingType) -> None:
|
||||
def change_aircraft(self, aircraft: Optional[FlyingType]) -> None:
|
||||
if self.aircraft == aircraft:
|
||||
return
|
||||
self.aircraft = aircraft
|
||||
@ -41,6 +41,8 @@ class QOriginAirfieldSelector(QComboBox):
|
||||
|
||||
def rebuild_selector(self) -> None:
|
||||
self.clear()
|
||||
if self.aircraft is None:
|
||||
return
|
||||
for origin in self.origins:
|
||||
if not origin.can_operate(self.aircraft):
|
||||
continue
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user