]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
remove memory leaks uninitalised memory read, etc...
authorptv <ptv@opencascade.com>
Fri, 14 Jul 2006 05:43:55 +0000 (05:43 +0000)
committerptv <ptv@opencascade.com>
Fri, 14 Jul 2006 05:43:55 +0000 (05:43 +0000)
noticed with Rational Purify on Windows

src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx
src/SalomeApp/SalomeApp_Application.cxx
src/Session/Session_ServerLauncher.cxx
src/Session/Session_ServerThread.cxx

index d2f73a653d97a4ccd1d10199cd7e501c56cd7d40..8ea7457cbf0248e21f1f02f0613f5aa24e5191bb 100644 (file)
@@ -825,9 +825,13 @@ Engines::Component_var SALOME_PYQT_Module::getEngine() const
  */
 QString SALOME_PYQT_Module::engineIOR() const
 {
+  QString anIOR = QString::null;
   if ( !CORBA::is_nil( getEngine() ) )
-    return QString( getApp()->orb()->object_to_string( getEngine() ) );
-  return QString( "" );
+  {
+    CORBA::String_var objStr = getApp()->orb()->object_to_string( getEngine() );
+    anIOR = QString( objStr.in() );
+  }
+  return anIOR;
 }
 
 /*!
index 5e73de8a68d0e045911a1063dcb3b84bd7447f67..1f2f5eb90103ea81a3052c491bf6fc6132bd403b 100644 (file)
@@ -742,7 +742,10 @@ QString SalomeApp_Application::defaultEngineIOR()
   QString anIOR( "" );
   CORBA::Object_ptr anEngine = namingService()->Resolve( "/SalomeAppEngine" );
   if ( !CORBA::is_nil( anEngine ) )
-    anIOR = orb()->object_to_string( anEngine );
+  {
+    CORBA::String_var objStr = orb()->object_to_string( anEngine );
+    anIOR = QString( objStr.in() );
+  }
   return anIOR;
 }
 
index d4b05541603a2f89849f7704f4e7d963badcc743..0604c7731e7dda0cfb892bbff282004e61837080 100755 (executable)
@@ -190,7 +190,7 @@ void Session_ServerLauncher::ActivateAll()
     {
       for (int i=0; i<argc-1; i++)
        //argv[i+1] = _argCopy[(*itServ)._firstArg + i].c_str();
-       argv[i+1] = _argv[(*itServ)._firstArg + i];
+             argv[i+1] = _argv[(*itServ)._firstArg + i];
     }
 
     std::cout << "*** activating [" << argc << "] : " << argv[0] << std::endl;
@@ -200,6 +200,8 @@ void Session_ServerLauncher::ActivateAll()
     _serverThreads.push_front(aServerThread);
     
     aServerThread->Init();
+    free( argv[0] );
+    delete[] argv;
   }
 
   // Always launch Session Server
@@ -211,8 +213,8 @@ void Session_ServerLauncher::ActivateAll()
   Session_SessionThread* aServerThread
     = new Session_SessionThread(argc, argv, _orb,_root_poa,_SessionMutex,_SessionStarted);
   _serverThreads.push_front(aServerThread);
-
   aServerThread->Init();
+  delete[] argv;
 }
 
 /*! 
index d9ef4f806902ba74c26c36a56cdaf4c6bbf6aedf..1407cf4a27fd6c2e1d156bbea3f39937de94b679 100755 (executable)
@@ -80,7 +80,11 @@ Session_ServerThread::Session_ServerThread(int argc,
 {
   //MESSAGE("Session_ServerThread Constructor " << argv[0]);
   _argc = argc;
-  _argv = argv;
+  _argv = new char*[ _argc + 1 ];
+  _argv[_argc] = 0;
+  for (int i = 0; i < _argc; i++ )
+    _argv[i] = strdup( argv[i] );
+
   _orb = CORBA::ORB::_duplicate(orb);
   _root_poa = PortableServer::POA::_duplicate(poa);
   _servType =-1;
@@ -94,6 +98,10 @@ Session_ServerThread::Session_ServerThread(int argc,
 Session_ServerThread::~Session_ServerThread()
 {
   //MESSAGE("~Session_ServerThread "<< _argv[0]);
+  delete _NS;
+  for (int i = 0; i <_argc ; i++ )
+    free( _argv[i] );
+  delete[] _argv;
 }
 
 /*! 
@@ -283,10 +291,10 @@ void Session_ServerThread::ActivateRegistry(int argc,
          INFOS("RegistryService servant already existing" );
          ASSERT(0);
        }
-      catch( const ServiceUnreachable &ex )
+      catch( const ServiceUnreachable &/*ex*/ )
        {
        }
-      catch( const CORBA::Exception &exx )
+      catch( const CORBA::Exception &/*exx*/ )
        {
        }
       string absoluteName = string("/") + registryName;
@@ -422,10 +430,14 @@ void Session_ServerThread::ActivateEngine(int /*argc*/, char ** /*argv*/)
       {
        INFOS("SalomeApp_Engine thread started");
        SalomeApp_Engine_i* anEngine = new SalomeApp_Engine_i();
-       /*PortableServer::ObjectId_var id = */_root_poa->activate_object( anEngine );
+  // declare variable and get value for them to avoid compilation warning of unused variable
+  // this variable is necessary to avoid memory leak of memory allocated in corba
+  PortableServer::ObjectId_var id = 0;
+  id = _root_poa->activate_object( anEngine );
+       ///*PortableServer::ObjectId_var id = */_root_poa->activate_object( anEngine );
        INFOS("poa->activate_object( SalomeApp_Engine )");
       
-       CORBA::Object_ptr obj = anEngine->_this();
+       CORBA::Object_var obj = anEngine->_this();
        _NS->Register( obj ,"/SalomeAppEngine");
 
       }