Fix possible None-exceptions in weather selector

This commit is contained in:
Raffson
2024-07-01 18:56:10 +02:00
parent e9a14f066a
commit 1df042fcc6
3 changed files with 15 additions and 8 deletions

View File

@@ -8,7 +8,7 @@ from game.weather.clouds import Clouds
class DcsCloudDensitySelector(QHBoxLayout):
def __init__(self, clouds: Clouds) -> None:
def __init__(self, clouds: Optional[Clouds]) -> None:
super().__init__()
self.unit_changing = False
@@ -17,7 +17,8 @@ class DcsCloudDensitySelector(QHBoxLayout):
self.density = QSlider(Qt.Orientation.Horizontal)
self.density.setRange(0, 10)
self.density.setValue(clouds.density)
if clouds:
self.density.setValue(clouds.density)
self.density.valueChanged.connect(self.on_slider_change)
self.addWidget(self.density, 1)