From 81d01817d7b1d89fba0a5bcec43b7412a2a14c25 Mon Sep 17 00:00:00 2001 From: prascle Date: Sun, 8 Feb 2004 22:12:26 +0000 Subject: [PATCH] PR: SALOME_Session_QThread is a singleton --- src/Session/SALOME_Session_QThread.cxx | 16 ++++++++++++++++ src/Session/SALOME_Session_QThread.hxx | 6 +++++- src/Session/SALOME_Session_i.cxx | 3 ++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Session/SALOME_Session_QThread.cxx b/src/Session/SALOME_Session_QThread.cxx index 4e075d495..5af3d908a 100644 --- a/src/Session/SALOME_Session_QThread.cxx +++ b/src/Session/SALOME_Session_QThread.cxx @@ -48,6 +48,8 @@ using namespace std; #include #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, QMutex *theGUIMutex) : QThread() { + INFOS("Creation SALOME_Session_QThread"); _qappl = 0 ; _mw = 0 ; _argc = argc ; @@ -64,6 +67,19 @@ SALOME_Session_QThread::SALOME_Session_QThread(int argc, char ** argv, QMutex *t _GUIMutex = theGUIMutex; } ; +//============================================================================= +/*! + * + */ +//============================================================================= + + SALOME_Session_QThread* SALOME_Session_QThread::Instance(int argc, char ** argv, QMutex *theGUIMutex) +{ + if (_singleton == 0) _singleton = new SALOME_Session_QThread(argc, argv, theGUIMutex); + return _singleton; + +} + //============================================================================= /*! run * Creates one QApplication for the all the session life. diff --git a/src/Session/SALOME_Session_QThread.hxx b/src/Session/SALOME_Session_QThread.hxx index a61f5dc72..d811680d7 100644 --- a/src/Session/SALOME_Session_QThread.hxx +++ b/src/Session/SALOME_Session_QThread.hxx @@ -41,7 +41,7 @@ class SALOME_Session_QThread: public QThread { public: - SALOME_Session_QThread(int argc, char ** argv, QMutex *theGUIMutex) ; + static SALOME_Session_QThread* Instance(int argc, char ** argv, QMutex *theGUIMutex); //! launch the Qt main window of the GUI on a separate thread virtual void run() ; @@ -58,6 +58,10 @@ protected: QMutex *_GUIMutex; SALOMEGUI_Application* _mw ; + SALOME_Session_QThread(int argc, char ** argv, QMutex *theGUIMutex) ; + +private: + static SALOME_Session_QThread* _singleton; } ; #endif diff --git a/src/Session/SALOME_Session_i.cxx b/src/Session/SALOME_Session_i.cxx index e267e55d1..18b3756c1 100644 --- a/src/Session/SALOME_Session_i.cxx +++ b/src/Session/SALOME_Session_i.cxx @@ -54,7 +54,8 @@ 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, &_GUIMutex) ; + //_IAPPThread = new SALOME_Session_QThread(_argc, _argv, &_GUIMutex) ; + _IAPPThread = SALOME_Session_QThread::Instance(_argc, _argv, &_GUIMutex) ; _isGUI = FALSE ; _runningStudies= 0 ; _orb = CORBA::ORB::_duplicate(orb) ; -- 2.39.2