Salome HOME
PR : Singleton for SALOME_Session_QThread
authorprascle <prascle>
Fri, 12 Mar 2004 18:02:24 +0000 (18:02 +0000)
committerprascle <prascle>
Fri, 12 Mar 2004 18:02:24 +0000 (18:02 +0000)
src/Session/SALOME_Session_QThread.cxx
src/Session/SALOME_Session_QThread.hxx
src/Session/SALOME_Session_i.cxx

index 8531be10fc1e303a8a0adeb9e5bdf8f293d46a42..8c598f1dadc30b28bde50372b2b76974a0583b01 100644 (file)
@@ -48,6 +48,8 @@ using namespace std;
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS)
 
+SALOME_Session_QThread* SALOME_Session_QThread::_singleton = 0;
+
 //=============================================================================
 /*! SALOME_Session_QThread
  *  constructor
@@ -56,6 +58,7 @@ using namespace std;
 
 SALOME_Session_QThread::SALOME_Session_QThread(int argc, char ** argv) : QThread()
 {
+  INFOS("Creation SALOME_Session_QThread");
   _qappl = 0 ;
   _mw = 0 ;
   _argc = argc ;
@@ -63,6 +66,19 @@ SALOME_Session_QThread::SALOME_Session_QThread(int argc, char ** argv) : QThread
   _NS = 0 ;
 } ;
 
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+
+  SALOME_Session_QThread* SALOME_Session_QThread::Instance(int argc, char ** argv)
+{
+  if (_singleton == 0) _singleton = new SALOME_Session_QThread(argc, argv);
+  return _singleton;
+
+}
+
 //=============================================================================
 /*! run
  *  Creates one QApplication for the all the session life.
index 9e9941bd7814552fbc47286b31d00b2b4e4bd7b7..eac1da8d65ceb0be7fe031e362d872e5f2271783 100644 (file)
@@ -41,7 +41,7 @@ class SALOME_Session_QThread: public QThread
 {
 
 public:
-  SALOME_Session_QThread(int argc, char ** argv) ;
+  static SALOME_Session_QThread* Instance(int argc, char ** argv);
 
   //! launch the Qt main window of the GUI on a separate thread
   virtual void run() ;
@@ -57,6 +57,10 @@ protected:
   QApplication *_qappl ;
 
   SALOMEGUI_Application* _mw ;
+  SALOME_Session_QThread(int argc, char ** argv);
+
+private:
+  static SALOME_Session_QThread* _singleton;
 } ;
 
 #endif
index fb2d92a94031fed84a862a671fa5b83461df285d..154848f2119832547e2864b461b96d77ea671cf8 100644 (file)
@@ -52,7 +52,7 @@ SALOME_Session_i::SALOME_Session_i(int argc, char ** argv, CORBA::ORB_ptr orb, P
 {
   _argc = argc ;
   _argv = argv ;
-  _IAPPThread = new SALOME_Session_QThread(_argc, _argv) ;
+  _IAPPThread = SALOME_Session_QThread::Instance(_argc, _argv);
   _isGUI = FALSE ;
   _runningStudies= 0 ;
   _orb = CORBA::ORB::_duplicate(orb) ;