From 7350855ca081bf6418d73e548684bbab78a78303 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 23 Oct 2023 19:10:17 +0200 Subject: [PATCH] Gui: fix possible crash when opening DlgSettingsLightSources --- .../DlgSettingsLightSources.cpp | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Gui/PreferencePages/DlgSettingsLightSources.cpp b/src/Gui/PreferencePages/DlgSettingsLightSources.cpp index 9ca7fc8df0..7fc8e25e1a 100644 --- a/src/Gui/PreferencePages/DlgSettingsLightSources.cpp +++ b/src/Gui/PreferencePages/DlgSettingsLightSources.cpp @@ -190,22 +190,28 @@ void DlgSettingsLightSources::loadDirection() void DlgSettingsLightSources::toggleLight(bool on) { - view->getHeadlight()->on = on; + if (view) { + view->getHeadlight()->on = on; + } } void DlgSettingsLightSources::lightIntensity(int value) { - float intensity = float(value) / 100.0F; - view->getHeadlight()->intensity = intensity; + if (view) { + float intensity = float(value) / 100.0F; + view->getHeadlight()->intensity = intensity; + } } void DlgSettingsLightSources::lightColor() { - QColor color = ui->light1Color->color(); - double red = color.redF(); - double green = color.greenF(); - double blue = color.blueF(); - view->getHeadlight()->color = SbColor(float(red), float(green), float(blue)); + if (view) { + QColor color = ui->light1Color->color(); + double red = color.redF(); + double green = color.greenF(); + double blue = color.blueF(); + view->getHeadlight()->color = SbColor(float(red), float(green), float(blue)); + } } void DlgSettingsLightSources::changeEvent(QEvent* event)