From: spo Date: Tue, 17 Nov 2015 13:02:22 +0000 (+0300) Subject: Issue #1093: Validator for parameter name duplication X-Git-Tag: V_2.0.0~27 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ce1983dbf66ea6b6e33196cbd96076ed0f8726f5;p=modules%2Fshaper.git Issue #1093: Validator for parameter name duplication --- diff --git a/src/ParametersPlugin/ParametersPlugin_Parameter.cpp b/src/ParametersPlugin/ParametersPlugin_Parameter.cpp index c51ae80de..1dc9a13ac 100644 --- a/src/ParametersPlugin/ParametersPlugin_Parameter.cpp +++ b/src/ParametersPlugin/ParametersPlugin_Parameter.cpp @@ -65,7 +65,7 @@ void ParametersPlugin_Parameter::updateName() setResult(aParam); } -void ParametersPlugin_Parameter::updateExpression() +bool ParametersPlugin_Parameter::updateExpression() { std::string anExpression = string(EXPRESSION_ID())->value(); @@ -73,25 +73,21 @@ void ParametersPlugin_Parameter::updateExpression() double aValue = evaluate(anExpression, outErrorMessage); data()->string(EXPRESSION_ERROR_ID())->setValue(outErrorMessage); - if (!outErrorMessage.empty()) { - setError("Expression error.", false); - data()->execState(ModelAPI_StateExecFailed); - return; - } + if (!outErrorMessage.empty()) + return false; ResultParameterPtr aParam = document()->createParameter(data()); AttributeDoublePtr aValueAttribute = aParam->data()->real(ModelAPI_ResultParameter::VALUE()); aValueAttribute->setValue(aValue); setResult(aParam); - - setError("", false); - data()->execState(ModelAPI_StateDone); + return true; } void ParametersPlugin_Parameter::execute() { updateName(); - updateExpression(); + if (!updateExpression()) + setError("Expression error.", false); } double ParametersPlugin_Parameter::evaluate(const std::string& theExpression, std::string& theError) diff --git a/src/ParametersPlugin/ParametersPlugin_Parameter.h b/src/ParametersPlugin/ParametersPlugin_Parameter.h index 229f8f217..47a0d3072 100644 --- a/src/ParametersPlugin/ParametersPlugin_Parameter.h +++ b/src/ParametersPlugin/ParametersPlugin_Parameter.h @@ -86,7 +86,7 @@ class ParametersPlugin_Parameter : public ModelAPI_Feature /// Updates name of the parameter void updateName(); /// Updates expression of the parameter - void updateExpression(); + bool updateExpression(); private: std::shared_ptr myInterp;