From ce1983dbf66ea6b6e33196cbd96076ed0f8726f5 Mon Sep 17 00:00:00 2001 From: spo Date: Tue, 17 Nov 2015 16:02:22 +0300 Subject: [PATCH] Issue #1093: Validator for parameter name duplication --- .../ParametersPlugin_Parameter.cpp | 16 ++++++---------- .../ParametersPlugin_Parameter.h | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) 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; -- 2.39.2