From: Anthony Geay Date: Fri, 25 Aug 2023 14:35:26 +0000 (+0200) Subject: [EDF27816] : Fix bug presence of proxy into a list X-Git-Tag: emc2p_1.4.0-rc1~6 X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fyacs.git;a=commitdiff_plain;h=4843811e2be7670a4fe2140a8f883a10b1da172f [EDF27816] : Fix bug presence of proxy into a list --- diff --git a/src/runtime/PythonNode.cxx b/src/runtime/PythonNode.cxx index 001080045..f82b88fe0 100644 --- a/src/runtime/PythonNode.cxx +++ b/src/runtime/PythonNode.cxx @@ -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 ) diff --git a/src/yacsloader_swig/Test/CMakeLists.txt b/src/yacsloader_swig/Test/CMakeLists.txt index b1092982d..7cfb889c3 100644 --- a/src/yacsloader_swig/Test/CMakeLists.txt +++ b/src/yacsloader_swig/Test/CMakeLists.txt @@ -41,6 +41,7 @@ IF(NOT WIN32) testResume.py testSave.py testSaveLoadRun.py + testYacsProxy.py testYacsLoaderSwig.py optim_plugin.py testValidationChecks.py diff --git a/src/yacsloader_swig/Test/CTestTestfileInstall.cmake b/src/yacsloader_swig/Test/CTestTestfileInstall.cmake index fbb046d97..a80c16935 100644 --- a/src/yacsloader_swig/Test/CTestTestfileInstall.cmake +++ b/src/yacsloader_swig/Test/CTestTestfileInstall.cmake @@ -74,6 +74,12 @@ IF(NOT WIN32) ENVIRONMENT "SALOME_EMB_SERVANT=1" ) + SET(TEST_NAME ${COMPONENT_NAME}_ProxyTest_swig) + ADD_TEST(${TEST_NAME} testYacsProxy.py) + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES + LABELS "${COMPONENT_NAME}" + ) + SET(TEST_NAME ${COMPONENT_NAME}_ValidationChecks_swig) ADD_TEST(${TEST_NAME} testValidationChecks.py) SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES