From: vsv Date: Fri, 24 Aug 2018 09:37:59 +0000 (+0300) Subject: Issue #2606: Use default value only if it is defined X-Git-Tag: SHAPER_V9_1_0RC1~27 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=422c7509f5ed8900fa0d3fb406268b5b7d9453b3;p=modules%2Fshaper.git Issue #2606: Use default value only if it is defined --- diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp index 7afe07635..0f521b50a 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp @@ -56,7 +56,7 @@ ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, const Config_WidgetAPI* theData) - : ModuleBase_ModelWidget(theParent, theData) + : ModuleBase_ModelWidget(theParent, theData), myHasDefault(false) { QFormLayout* aControlLay = new QFormLayout(this); ModuleBase_Tools::adjustMargins(aControlLay); @@ -101,11 +101,9 @@ ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, mySpinBox->setSingleStep(aStepVal); } - myDefaultVal = QString::fromStdString(getDefaultValue()).toDouble(&isOk); - if (isOk) + myDefaultVal = QString::fromStdString(getDefaultValue()).toDouble(&myHasDefault); + if (myHasDefault) mySpinBox->setValue(myDefaultVal); - else - myDefaultVal = 0; QString aTTip = translate(theData->widgetTooltip()); mySpinBox->setToolTip(aTTip); @@ -218,7 +216,7 @@ bool ModuleBase_WidgetDoubleValue::restoreValueCustom() aRef->setExpressionError(""); aRef->setExpressionInvalid(false); } - if (!aRef->isInitialized()) + if ((!aRef->isInitialized()) && myHasDefault) aRef->setValue(myDefaultVal); } return true; diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.h b/src/ModuleBase/ModuleBase_WidgetDoubleValue.h index 8e9055ab7..595cb8590 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.h +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.h @@ -90,6 +90,7 @@ protected: FeaturePtr myParameter; double myDefaultVal; + bool myHasDefault; }; #endif