Salome HOME
Fix a crash when initializing a ForEachLoop_pyobj.
authorOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Tue, 8 Sep 2015 12:50:45 +0000 (14:50 +0200)
committerOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Tue, 8 Sep 2015 12:50:45 +0000 (14:50 +0200)
There was a crash when you try to put the value ["a","b"] to the
port SmplsCollection of a ForEachLoop_pyobj.
EDF Salome.REx issue 11454.

src/runtime/RuntimeSALOME.cxx

index ab53fda574a0fe2e9e2a684a1f8219da0f672625..1727e64269ae4f1282f5ea286b9966505f4b4c6d 100644 (file)
@@ -1808,6 +1808,10 @@ std::string RuntimeSALOME::convertNeutralAsString(TypeCode * type, Any *data)
   PyObject* ob;
   if(data)
     {
+      // The call to PyGILState_Ensure was moved here because there was also
+      // a crash when calling convertNeutralPyObject with a sequence of pyobj.
+      // see also the comment below.
+      PyGILState_STATE gstate = PyGILState_Ensure();
       ob=convertNeutralPyObject(type,data);
       std::string s=convertPyObjectToString(ob);
 
@@ -1816,7 +1820,7 @@ std::string RuntimeSALOME::convertNeutralAsString(TypeCode * type, Any *data)
       // lock. I thus added the call to PyGILState_Ensure / PyGILState_Release. It worked fine in
       // Python 2.6 without this call. If anyone finds the real reason of this bug and another fix,
       // feel free to change this code.
-      PyGILState_STATE gstate = PyGILState_Ensure();
+      //PyGILState_STATE gstate = PyGILState_Ensure();
       Py_DECREF(ob);
       PyGILState_Release(gstate);
       return s;