From d038f6497a83ec6d7c4318fdfe6dda4ade6ec7a8 Mon Sep 17 00:00:00 2001 From: vsr Date: Mon, 21 Sep 2009 10:00:27 +0000 Subject: [PATCH] Integrate patch from C.Caremoli : fix memory leaks --- src/CAM/CAM_Application.cxx | 2 ++ src/Qtx/QtxWorkstack.cxx | 2 +- src/SalomeApp/SalomeApp_Application.cxx | 8 ++++---- src/SalomeApp/SalomeApp_DataObject.cxx | 2 +- src/Session/SALOME_Session_Server.cxx | 11 ++++++++--- src/Session/Session_ServerThread.cxx | 4 ++-- 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index b731d4c57..61aa42d96 100755 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -88,6 +88,8 @@ CAM_Application::CAM_Application( const bool autoLoad ) */ CAM_Application::~CAM_Application() { + for ( QList::const_iterator it = myModules.begin(); it != myModules.end(); ++it ) + delete *it; } /*! diff --git a/src/Qtx/QtxWorkstack.cxx b/src/Qtx/QtxWorkstack.cxx index bf888382b..d9409bb51 100644 --- a/src/Qtx/QtxWorkstack.cxx +++ b/src/Qtx/QtxWorkstack.cxx @@ -1508,7 +1508,7 @@ void QtxWorkstackChild::childEvent( QChildEvent* e ) */ QtxWorkstackTabBar::QtxWorkstackTabBar( QWidget* parent ) : QTabBar( parent ), - myId( -1 ) + myId( -1 ),myActive(false) { setDrawBase( true ); setElideMode( Qt::ElideNone ); diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index d03b3ac60..bea36e500 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -1078,15 +1078,15 @@ SALOMEDSClient_StudyManager* SalomeApp_Application::studyMgr() /*!Create and return SALOME_NamingService.*/ SALOME_NamingService* SalomeApp_Application::namingService() { - static SALOME_NamingService* _ns = new SALOME_NamingService( orb() ); - return _ns; + static SALOME_NamingService _ns(orb()); + return &_ns; } /*!Create and return SALOME_LifeCycleCORBA.*/ SALOME_LifeCycleCORBA* SalomeApp_Application::lcc() { - static SALOME_LifeCycleCORBA* _lcc = new SALOME_LifeCycleCORBA( namingService() ); - return _lcc; + static SALOME_LifeCycleCORBA _lcc( namingService() ); + return &_lcc; } /*!Return default engine IOR for light modules*/ diff --git a/src/SalomeApp/SalomeApp_DataObject.cxx b/src/SalomeApp/SalomeApp_DataObject.cxx index a05f501fa..6db6c32ca 100644 --- a/src/SalomeApp/SalomeApp_DataObject.cxx +++ b/src/SalomeApp/SalomeApp_DataObject.cxx @@ -275,7 +275,7 @@ QString SalomeApp_DataObject::toolTip( const int /*id*/ ) const if ( !CORBA::is_nil(aComponent) && aComponent->hasObjectInfo() ) { LightApp_RootObject* aRoot = dynamic_cast( root() ); if ( aRoot && aRoot->study() ) - return QString( aComponent->getObjectInfo( aRoot->study()->id(), entry().toLatin1().constData()) ); + return QString( (CORBA::String_var)aComponent->getObjectInfo( aRoot->study()->id(), entry().toLatin1().constData()) ); } } } diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index 46e753b13..a4f881c69 100755 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -581,9 +581,6 @@ int main( int argc, char **argv ) delete myServerLauncher; delete _NS; - PyGILState_STATE gstate = PyGILState_Ensure(); - Py_Finalize(); - try { orb->shutdown(0); } @@ -597,8 +594,16 @@ int main( int argc, char **argv ) // std::cerr << "Caught unexpected exception on destroy : ignored !!" << std::endl; } + PyGILState_STATE gstate = PyGILState_Ensure(); + //Destroy orb from python (for chasing memory leaks) + //PyRun_SimpleString("from omniORB import CORBA"); + //PyRun_SimpleString("orb=CORBA.ORB_init([''], CORBA.ORB_ID)"); + //PyRun_SimpleString("orb.destroy()"); + Py_Finalize(); + if ( shutdown ) killOmniNames(); + MESSAGE( "Salome_Session_Server:endofserver" ); return result; } diff --git a/src/Session/Session_ServerThread.cxx b/src/Session/Session_ServerThread.cxx index e46db7d48..e8c804011 100755 --- a/src/Session/Session_ServerThread.cxx +++ b/src/Session/Session_ServerThread.cxx @@ -265,10 +265,11 @@ void Session_ServerThread::ActivateRegistry(int argc, const char *registryName = "Registry"; Registry::Components_var varComponents; try { - RegistryService *ptrRegistry = SINGLETON_::Instance(); + RegistryService *ptrRegistry = new RegistryService; ptrRegistry->SessionName( ptrSessionName ); ptrRegistry->SetOrb(_orb); varComponents = ptrRegistry->_this(); + ptrRegistry->_remove_ref(); //let poa manage registry service deletion // The RegistryService must not already exist. try { @@ -283,7 +284,6 @@ void Session_ServerThread::ActivateRegistry(int argc, } string absoluteName = string("/") + registryName; _NS->Register( varComponents , absoluteName.c_str() ); - MESSAGE("On attend les requetes des clients"); } catch( const SALOME_Exception &ex ) { INFOS( "Communication Error : " << ex.what() ); -- 2.39.2