Salome HOME
Merge branch 'Dev_1.1.1' of newgeom:newgeom into Dev_1.2.0
[modules/shaper.git] / src / ParametersPlugin / ParametersPlugin_PyInterp.cpp
index 61b8cfd3326baf960cb579913b036b652a233aef..53659f23fdbd89ab61bc1438f5a380aa2575e536 100644 (file)
@@ -8,6 +8,7 @@
 #include <ParametersPlugin_PyInterp.h>
 
 #include <string>
+#include <stdexcept>
 
 ParametersPlugin_PyInterp::ParametersPlugin_PyInterp()
 : PyInterp_Interp()
@@ -68,6 +69,12 @@ void ParametersPlugin_PyInterp::extendLocalContext(const std::list<std::string>&
   }
 }
 
+void ParametersPlugin_PyInterp::clearLocalContext()
+{
+  PyLockWrapper lck;
+  PyDict_Clear(_local_context);
+}
+
 
 double ParametersPlugin_PyInterp::evaluate(const std::string& theExpression, std::string& theError)
 {
@@ -129,7 +136,14 @@ bool ParametersPlugin_PyInterp::initContext()
   }
   _global_context = PyModule_GetDict(m);          // get interpreter global variable context
   Py_INCREF(_global_context);
-  _local_context = _global_context;
+  _local_context = PyDict_New();
+  Py_INCREF(_local_context);
 
   return PyRun_SimpleString("from math import *") == 0;
 }
+
+void ParametersPlugin_PyInterp::closeContext()
+{
+  Py_XDECREF(_local_context);
+  PyInterp_Interp::closeContext();
+}