From: vsv Date: Thu, 26 Jul 2018 08:49:08 +0000 (+0300) Subject: Issue #2571: Clear error flag for integer input widget X-Git-Tag: SHAPER_V9_1_0RC1~73^2~24 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d3d6ac19c04c56dab59513833f7d1a91ea1b9596;p=modules%2Fshaper.git Issue #2571: Clear error flag for integer input widget --- diff --git a/src/ModuleBase/ModuleBase_WidgetIntValue.cpp b/src/ModuleBase/ModuleBase_WidgetIntValue.cpp index 176fea5fc..095f123c7 100644 --- a/src/ModuleBase/ModuleBase_WidgetIntValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetIntValue.cpp @@ -167,6 +167,10 @@ bool ModuleBase_WidgetIntValue::storeValueCustom() // it is important to set the empty text value to the attribute before set the value // because setValue tries to calculate the attribute value according to the // attribute current text + if (anAttribute->expressionInvalid()) { + anAttribute->setExpressionError(""); + anAttribute->setExpressionInvalid(false); + } anAttribute->setText(""); anAttribute->setValue(mySpinBox->value()); } @@ -181,21 +185,26 @@ bool ModuleBase_WidgetIntValue::restoreValueCustom() std::string aTextRepr = anAttribute->text(); if (!aTextRepr.empty()) { QString aText = QString::fromStdString(aTextRepr); - if (aText.endsWith('=')) { - if (!myParameter.get()) { - QString aName = aText.left(aText.indexOf('=')).trimmed(); - myParameter = ModuleBase_Tools::findParameter(aName); - } - /// If myParameter is empty then it was not created because of an error - if (!myParameter.get()) - return false; - - AttributeStringPtr aExprAttr = myParameter->string("expression"); - aText += aExprAttr->value().c_str(); - } + //if (aText.endsWith('=')) { + // if (!myParameter.get()) { + // QString aName = aText.left(aText.indexOf('=')).trimmed(); + // myParameter = ModuleBase_Tools::findParameter(aName); + // } + // /// If myParameter is empty then it was not created because of an error + // if (!myParameter.get()) + // return false; + + // AttributeStringPtr aExprAttr = myParameter->string("expression"); + // aText += aExprAttr->value().c_str(); + //} ModuleBase_Tools::setSpinText(mySpinBox, aText); } else { - ModuleBase_Tools::setSpinValue(mySpinBox, anAttribute->value()); + ModuleBase_Tools::setSpinValue(mySpinBox, + anAttribute->isInitialized() ? anAttribute->value() : 0); + if (anAttribute->isInitialized() && anAttribute->expressionInvalid()) { + anAttribute->setExpressionError(""); + anAttribute->setExpressionInvalid(false); + } } return true; }