From 6654ad28ef3bc6e40cfa57aa4aa01ecffb0e87cc Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 2 Jun 2022 17:07:50 +0300 Subject: [PATCH] Fixed a floating crash on first change of "Create new part" in preferences dialog. --- src/ModuleBase/ModuleBase_Preferences.cpp | 4 ---- src/SHAPERGUI/SHAPERGUI.cpp | 2 ++ src/SHAPERGUI/resources/LightApp.xml.in | 1 + src/XGUI/SHAPER.xml | 1 + 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ModuleBase/ModuleBase_Preferences.cpp b/src/ModuleBase/ModuleBase_Preferences.cpp index 0f4d2f121..004965fd4 100644 --- a/src/ModuleBase/ModuleBase_Preferences.cpp +++ b/src/ModuleBase/ModuleBase_Preferences.cpp @@ -177,10 +177,6 @@ void ModuleBase_Preferences::createGeneralTab(ModuleBase_IPrefMgr* thePref, int int actId = thePref->addPreference(QObject::tr("Create new part"), group, SUIT_PreferenceMgr::Bool, ModuleBase_Preferences::GENERAL_SECTION, "create_init_part"); - if (!resourceMgr()->hasValue(ModuleBase_Preferences::GENERAL_SECTION, "create_init_part")) - { // set default value: true - resourceMgr()->setValue(ModuleBase_Preferences::GENERAL_SECTION, "create_init_part", true); - } // Group related to running a python script group = thePref->addPreference(QObject::tr("Launching a python script"), generalTab, diff --git a/src/SHAPERGUI/SHAPERGUI.cpp b/src/SHAPERGUI/SHAPERGUI.cpp index bcdcd5f81..24f02c053 100644 --- a/src/SHAPERGUI/SHAPERGUI.cpp +++ b/src/SHAPERGUI/SHAPERGUI.cpp @@ -947,6 +947,8 @@ void SHAPERGUI::preferencesChanged(const QString& theSection, const QString& the QString aVal = aResMgr->stringValue(theSection, theParam); Config_Prop* aProp = Config_PropManager::findProp(theSection.toStdString(), theParam.toStdString()); + if (!aProp) + return; // invalid case, the property default value must be registered in XML file std::string aValue = aVal.toStdString(); if (aValue.empty()) { aValue = aProp->defaultValue(); diff --git a/src/SHAPERGUI/resources/LightApp.xml.in b/src/SHAPERGUI/resources/LightApp.xml.in index 9aa2e5006..a28831769 100644 --- a/src/SHAPERGUI/resources/LightApp.xml.in +++ b/src/SHAPERGUI/resources/LightApp.xml.in @@ -27,6 +27,7 @@ +
diff --git a/src/XGUI/SHAPER.xml b/src/XGUI/SHAPER.xml index ed65fcec5..d2ae66807 100644 --- a/src/XGUI/SHAPER.xml +++ b/src/XGUI/SHAPER.xml @@ -9,6 +9,7 @@ +
-- 2.39.2