From c985e9aa559291e31ab41fd5a0edd649a08762cf Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Fri, 25 Aug 2023 16:36:00 +0200 Subject: [PATCH] [EDF27816] : Fix bug presence of proxy into a list --- src/Container/SALOME_PyNode.py | 16 +++------------- src/Container/Test/testProxy.py | 2 +- src/KernelHelpers/KernelServices.cxx | 10 ++++++++++ src/KernelHelpers/KernelServices.hxx | 3 +++ src/KernelHelpers/KernelServices.i | 1 + 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/Container/SALOME_PyNode.py b/src/Container/SALOME_PyNode.py index df59850ca..1bb41877d 100644 --- a/src/Container/SALOME_PyNode.py +++ b/src/Container/SALOME_PyNode.py @@ -146,6 +146,7 @@ def IncrRefInFile(fname): cntb = f.read( GetSizeOfTCnt() ) cnt = TypeCounter.from_buffer_copy( cntb ).value with open(fname,"rb+") as f: + #import KernelServices ; KernelServices.EntryForDebuggerBreakPoint() f.write( bytes( TypeCounter(cnt+1) ) ) def DecrRefInFile(fname): @@ -154,11 +155,9 @@ def DecrRefInFile(fname): cntb = f.read( GetSizeOfTCnt() ) cnt = TypeCounter.from_buffer_copy( cntb ).value # + #import KernelServices ; KernelServices.EntryForDebuggerBreakPoint() if cnt == 1: - pass - #print("Remove {}".format(fname)) - #print("Remove {}".format(str(GetObjectFromFile(fname)[0]))) - #os.unlink( fname ) + os.unlink( fname ) else: with open(fname,"rb+") as f: f.write( bytes( TypeCounter(cnt-1) ) ) @@ -236,15 +235,6 @@ class BigObjectOnDiskBase: if self._destroy: DecrRefInFile( self._filename ) - def delDebug(self): - import os - if self._destroy: - if os.path.exists( self._filename ): - DecrRefInFile( self._filename ) - else: - import KernelServices - KernelServices.GenerateViolentMemoryFaultForTestPurpose() - def getFileName(self): return self._filename diff --git a/src/Container/Test/testProxy.py b/src/Container/Test/testProxy.py index 4ed4dce82..0dd0eeb38 100644 --- a/src/Container/Test/testProxy.py +++ b/src/Container/Test/testProxy.py @@ -98,7 +98,7 @@ j = a,b,c""" del ret3 import gc gc.collect(0) - #self.assertTrue( not os.path.exists( fn ) ) # at destruction of ret3 the corresponding pckl file must be destructed + self.assertTrue( not os.path.exists( fn ) ) # at destruction of ret3 the corresponding pckl file must be destructed cont.Shutdown() if __name__ == '__main__': diff --git a/src/KernelHelpers/KernelServices.cxx b/src/KernelHelpers/KernelServices.cxx index 1626958c9..c30aa41d1 100644 --- a/src/KernelHelpers/KernelServices.cxx +++ b/src/KernelHelpers/KernelServices.cxx @@ -19,6 +19,8 @@ #include "SALOME_KernelServices.hxx" +#include + void RegisterCompoInternal(const std::string& compoName, const std::string& compoIOR) { CORBA::ORB_ptr orb = KERNEL::getORB(); @@ -42,3 +44,11 @@ void GenerateViolentMemoryFaultForTestPurpose() double *a = nullptr; *a = 0; } + +/*! + * This method wrapped into Python is useful to have a break point in C++ when complex python script is invoked in the stack + */ +void EntryForDebuggerBreakPoint() +{ + std::cout << "b KernelServices.cxx:53" << std::endl; +} diff --git a/src/KernelHelpers/KernelServices.hxx b/src/KernelHelpers/KernelServices.hxx index 5cb57378d..52f965a2f 100644 --- a/src/KernelHelpers/KernelServices.hxx +++ b/src/KernelHelpers/KernelServices.hxx @@ -18,9 +18,12 @@ // #ifndef __KERNELSERVICES_HXX__ #define __KERNELSERVICES_HXX__ + #include void RegisterCompoInternal(const std::string& compoName, const std::string& compoIOR); std::string RetrieveCompoInternal(const std::string& compoName); void GenerateViolentMemoryFaultForTestPurpose(); +void EntryForDebuggerBreakPoint(); + #endif diff --git a/src/KernelHelpers/KernelServices.i b/src/KernelHelpers/KernelServices.i index c882b6584..e884001dd 100644 --- a/src/KernelHelpers/KernelServices.i +++ b/src/KernelHelpers/KernelServices.i @@ -59,6 +59,7 @@ public: void RegisterCompoInternal(const std::string& compoName, const std::string& compoIOR); std::string RetrieveCompoInternal(const std::string& compoName); void GenerateViolentMemoryFaultForTestPurpose(); + void EntryForDebuggerBreakPoint(); } %pythoncode %{ -- 2.39.2