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."""
|
"""Combo box for selecting a departure airfield."""
|
||||||
from typing import Iterable
|
from typing import Iterable, Optional
|
||||||
|
|
||||||
from PySide2.QtWidgets import QComboBox
|
from PySide2.QtWidgets import QComboBox
|
||||||
from dcs.unittype import FlyingType
|
from dcs.unittype import FlyingType
|
||||||
@ -18,7 +18,7 @@ class QArrivalAirfieldSelector(QComboBox):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
destinations: Iterable[ControlPoint],
|
destinations: Iterable[ControlPoint],
|
||||||
aircraft: AircraftType,
|
aircraft: Optional[AircraftType],
|
||||||
optional_text: str,
|
optional_text: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@ -28,7 +28,7 @@ class QArrivalAirfieldSelector(QComboBox):
|
|||||||
self.rebuild_selector()
|
self.rebuild_selector()
|
||||||
self.setCurrentIndex(0)
|
self.setCurrentIndex(0)
|
||||||
|
|
||||||
def change_aircraft(self, aircraft: FlyingType) -> None:
|
def change_aircraft(self, aircraft: Optional[FlyingType]) -> None:
|
||||||
if self.aircraft == aircraft:
|
if self.aircraft == aircraft:
|
||||||
return
|
return
|
||||||
self.aircraft = aircraft
|
self.aircraft = aircraft
|
||||||
@ -36,6 +36,8 @@ class QArrivalAirfieldSelector(QComboBox):
|
|||||||
|
|
||||||
def rebuild_selector(self) -> None:
|
def rebuild_selector(self) -> None:
|
||||||
self.clear()
|
self.clear()
|
||||||
|
if self.aircraft is None:
|
||||||
|
return
|
||||||
for destination in self.destinations:
|
for destination in self.destinations:
|
||||||
if destination.can_operate(self.aircraft):
|
if destination.can_operate(self.aircraft):
|
||||||
self.addItem(destination.name, destination)
|
self.addItem(destination.name, destination)
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
"""Combo box for selecting a departure airfield."""
|
"""Combo box for selecting a departure airfield."""
|
||||||
from typing import Iterable
|
from typing import Iterable, Optional
|
||||||
|
|
||||||
from PySide2.QtCore import Signal
|
from PySide2.QtCore import Signal
|
||||||
from PySide2.QtWidgets import QComboBox
|
from PySide2.QtWidgets import QComboBox
|
||||||
@ -23,7 +23,7 @@ class QOriginAirfieldSelector(QComboBox):
|
|||||||
self,
|
self,
|
||||||
global_inventory: GlobalAircraftInventory,
|
global_inventory: GlobalAircraftInventory,
|
||||||
origins: Iterable[ControlPoint],
|
origins: Iterable[ControlPoint],
|
||||||
aircraft: AircraftType,
|
aircraft: Optional[AircraftType],
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.global_inventory = global_inventory
|
self.global_inventory = global_inventory
|
||||||
@ -33,7 +33,7 @@ class QOriginAirfieldSelector(QComboBox):
|
|||||||
self.currentIndexChanged.connect(self.index_changed)
|
self.currentIndexChanged.connect(self.index_changed)
|
||||||
self.setSizeAdjustPolicy(self.AdjustToContents)
|
self.setSizeAdjustPolicy(self.AdjustToContents)
|
||||||
|
|
||||||
def change_aircraft(self, aircraft: FlyingType) -> None:
|
def change_aircraft(self, aircraft: Optional[FlyingType]) -> None:
|
||||||
if self.aircraft == aircraft:
|
if self.aircraft == aircraft:
|
||||||
return
|
return
|
||||||
self.aircraft = aircraft
|
self.aircraft = aircraft
|
||||||
@ -41,6 +41,8 @@ class QOriginAirfieldSelector(QComboBox):
|
|||||||
|
|
||||||
def rebuild_selector(self) -> None:
|
def rebuild_selector(self) -> None:
|
||||||
self.clear()
|
self.clear()
|
||||||
|
if self.aircraft is None:
|
||||||
|
return
|
||||||
for origin in self.origins:
|
for origin in self.origins:
|
||||||
if not origin.can_operate(self.aircraft):
|
if not origin.can_operate(self.aircraft):
|
||||||
continue
|
continue
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user