Salome HOME
[EDF27816] : Fix bug presence of proxy into a list
[modules/yacs.git] / src / runtime / PythonNode.cxx
index 0010800456e0df12dcfc4fe9a9ecad873889d034..f82b88fe0a7a94f321f6509ee2a013f0a00a23ad 100644 (file)
@@ -332,7 +332,24 @@ bool PythonEntry::IsProxy( PyObject *ob )
 {
   if(!_pyClsBigObject)
     return false;
-  return PyObject_IsInstance( ob, _pyClsBigObject) == 1;
+  if( PyObject_IsInstance( ob, _pyClsBigObject) == 1 )
+  {
+    return true;
+  }
+  else
+  {
+    if( PyList_Check( ob ) )
+    {
+      auto sz = PyList_Size( ob );
+      for( auto i = 0 ; i < sz ; ++i )
+      {
+        PyObject *elt = PyList_GetItem( ob, i );
+        if( PythonEntry::IsProxy(elt) )
+          return true;
+      }
+    }
+  }
+  return false;
 }
 
 bool PythonEntry::GetDestroyStatus( PyObject *ob )
@@ -349,6 +366,19 @@ bool PythonEntry::GetDestroyStatus( PyObject *ob )
     }
     return false;
   }
+  else
+  {
+    if( PyList_Check( ob ) )
+    {
+      auto sz = PyList_Size( ob );
+      for( auto i = 0 ; i < sz ; ++i )
+      {
+        PyObject *elt = PyList_GetItem( ob, i );
+        if( PythonEntry::GetDestroyStatus(elt) )
+          return true;
+      }
+    }
+  }
   return false;
 }
 
@@ -361,6 +391,18 @@ void PythonEntry::IfProxyDoSomething( PyObject *ob, const char *meth )
     AutoPyRef unlinkOnDestructor = PyObject_GetAttrString(ob,meth);
     AutoPyRef tmp = PyObject_CallFunctionObjArgs(unlinkOnDestructor,nullptr);
   }
+  else
+  {
+    if( PyList_Check( ob ) )
+    {
+      auto sz = PyList_Size( ob );
+      for( auto i = 0 ; i < sz ; ++i )
+      {
+        PyObject *elt = PyList_GetItem( ob, i );
+        PythonEntry::IfProxyDoSomething( elt, meth );
+      }
+    }
+  }
 }
 
 void PythonEntry::DoNotTouchFileIfProxy( PyObject *ob )