From ffd66f04150b6aa8f8b3e5be00c642d771419c4e Mon Sep 17 00:00:00 2001 From: prascle Date: Fri, 12 Mar 2004 18:02:24 +0000 Subject: [PATCH] PR : Singleton for SALOME_Session_QThread --- src/Session/SALOME_Session_QThread.cxx | 16 ++++++++++++++++ src/Session/SALOME_Session_QThread.hxx | 6 +++++- src/Session/SALOME_Session_i.cxx | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/Session/SALOME_Session_QThread.cxx b/src/Session/SALOME_Session_QThread.cxx index 8531be10f..8c598f1da 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) : 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. diff --git a/src/Session/SALOME_Session_QThread.hxx b/src/Session/SALOME_Session_QThread.hxx index 9e9941bd7..eac1da8d6 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) ; + 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 diff --git a/src/Session/SALOME_Session_i.cxx b/src/Session/SALOME_Session_i.cxx index fb2d92a94..154848f21 100644 --- a/src/Session/SALOME_Session_i.cxx +++ b/src/Session/SALOME_Session_i.cxx @@ -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) ; -- 2.39.2