From: sbh Date: Thu, 16 Apr 2015 14:18:06 +0000 (+0300) Subject: Issue #464 just clear local context of the interpreter, not initialize it from scratch X-Git-Tag: V_1.1.0~24 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4b42d82d7269a3146fbe09d88f5da936bf49452f;p=modules%2Fshaper.git Issue #464 just clear local context of the interpreter, not initialize it from scratch --- diff --git a/src/ParametersPlugin/ParametersPlugin_Parameter.cpp b/src/ParametersPlugin/ParametersPlugin_Parameter.cpp index 70840ccff..48f5d7312 100644 --- a/src/ParametersPlugin/ParametersPlugin_Parameter.cpp +++ b/src/ParametersPlugin/ParametersPlugin_Parameter.cpp @@ -18,6 +18,7 @@ ParametersPlugin_Parameter::ParametersPlugin_Parameter() { myInterp = new ParametersPlugin_PyInterp(); + myInterp->initialize(); } ParametersPlugin_Parameter::~ParametersPlugin_Parameter() @@ -76,7 +77,7 @@ void ParametersPlugin_Parameter::execute() double ParametersPlugin_Parameter::evaluate(const std::string& theExpression, std::string& theError) { - myInterp->initialize(); + std::list anExprParams = myInterp->compile(theExpression); // find expression's params in the model std::list aContext; @@ -92,6 +93,6 @@ double ParametersPlugin_Parameter::evaluate(const std::string& theExpression, st } myInterp->extendLocalContext(aContext); double result = myInterp->evaluate(theExpression, theError); - myInterp->destroy(); + myInterp->clearLocalContext(); return result; } diff --git a/src/ParametersPlugin/ParametersPlugin_PyInterp.cpp b/src/ParametersPlugin/ParametersPlugin_PyInterp.cpp index 7a5f42c4f..4afbfaa2a 100644 --- a/src/ParametersPlugin/ParametersPlugin_PyInterp.cpp +++ b/src/ParametersPlugin/ParametersPlugin_PyInterp.cpp @@ -69,6 +69,12 @@ void ParametersPlugin_PyInterp::extendLocalContext(const std::list& } } +void ParametersPlugin_PyInterp::clearLocalContext() +{ + PyLockWrapper lck; + PyDict_Clear(_local_context); +} + double ParametersPlugin_PyInterp::evaluate(const std::string& theExpression, std::string& theError) { diff --git a/src/ParametersPlugin/ParametersPlugin_PyInterp.h b/src/ParametersPlugin/ParametersPlugin_PyInterp.h index 4151f4e23..0e3cdee56 100644 --- a/src/ParametersPlugin/ParametersPlugin_PyInterp.h +++ b/src/ParametersPlugin/ParametersPlugin_PyInterp.h @@ -22,6 +22,7 @@ class PARAMETERSPLUGIN_EXPORT ParametersPlugin_PyInterp : public PyInterp_Interp std::list compile(const std::string&); void extendLocalContext(const std::list&); + void clearLocalContext(); double evaluate(const std::string&, std::string&); protected: