From: vsv Date: Fri, 24 Aug 2018 09:40:15 +0000 (+0300) Subject: Use default value only in case it is defined X-Git-Tag: SHAPER_V9_1_0RC1~26 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=55c3c4e511921a0985da7485fd1762b66f0b3b88;p=modules%2Fshaper.git Use default value only in case it is defined --- diff --git a/src/ModuleBase/ModuleBase_WidgetIntValue.cpp b/src/ModuleBase/ModuleBase_WidgetIntValue.cpp index 12931a997..b99e1d4eb 100644 --- a/src/ModuleBase/ModuleBase_WidgetIntValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetIntValue.cpp @@ -52,7 +52,7 @@ ModuleBase_WidgetIntValue::ModuleBase_WidgetIntValue(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); @@ -91,11 +91,9 @@ ModuleBase_WidgetIntValue::ModuleBase_WidgetIntValue(QWidget* theParent, mySpinBox->setSingleStep(aStepVal); } - myDefVal = QString::fromStdString(getDefaultValue()).toInt(&isOk); + myDefVal = QString::fromStdString(getDefaultValue()).toInt(&myHasDefault); if (isOk) mySpinBox->setValue(myDefVal); - else - myDefVal = 0; QString aTTip = translate(theData->widgetTooltip()); mySpinBox->setToolTip(aTTip); @@ -206,7 +204,7 @@ bool ModuleBase_WidgetIntValue::restoreValueCustom() anAttribute->setExpressionError(""); anAttribute->setExpressionInvalid(false); } - if (!anAttribute->isInitialized()) + if ((!anAttribute->isInitialized()) && myHasDefault) anAttribute->setValue(myDefVal); } return true; diff --git a/src/ModuleBase/ModuleBase_WidgetIntValue.h b/src/ModuleBase/ModuleBase_WidgetIntValue.h index 3d6030844..4637af46c 100644 --- a/src/ModuleBase/ModuleBase_WidgetIntValue.h +++ b/src/ModuleBase/ModuleBase_WidgetIntValue.h @@ -85,6 +85,7 @@ protected: FeaturePtr myParameter; int myDefVal; + bool myHasDefault; }; #endif