From d3d6ac19c04c56dab59513833f7d1a91ea1b9596 Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 26 Jul 2018 11:49:08 +0300 Subject: [PATCH] Issue #2571: Clear error flag for integer input widget --- src/ModuleBase/ModuleBase_WidgetIntValue.cpp | 35 ++++++++++++-------- 1 file changed, 22 insertions(+), 13 deletions(-) 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; } -- 2.39.2