#include "SALOME_Session_i.hxx"
#include "SALOME_NamingService.hxx"
-#include "SALOME_Session_QThread.hxx"
+#include "SALOME_Event.hxx"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
*/
//=============================================================================
-SALOME_Session_i::SALOME_Session_i(int argc, char ** argv, CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, QMutex* GUIMutex)
+SALOME_Session_i::SALOME_Session_i(int argc,
+ char ** argv,
+ CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ QMutex* GUIMutex,
+ QWaitCondition* GUILauncher)
{
_argc = argc ;
_argv = argv ;
_orb = CORBA::ORB::_duplicate(orb) ;
_poa = PortableServer::POA::_duplicate(poa) ;
_GUIMutex = GUIMutex;
- MESSAGE("constructor end");
+ _GUILauncher = GUILauncher;
+ //MESSAGE("constructor end");
}
//=============================================================================
Engines::Component_ptr SALOME_Session_i::GetVisuComponent()
{
- MESSAGE("SALOME_Session_i::GetVisuGen");
+ //MESSAGE("SALOME_Session_i::GetVisuGen");
typedef Engines::Component_ptr TGetImpl(CORBA::ORB_ptr,
PortableServer::POA_ptr,
SALOME_NamingService*,QMutex*);
SALOME_Session_i::~SALOME_Session_i()
{
- MESSAGE("destructor end");
+ //MESSAGE("destructor end");
}
//=============================================================================
{
INFOS("Caught unknown exception from Naming Service");
}
- MESSAGE("Session registered in Naming Service");
+ //MESSAGE("Session registered in Naming Service");
}
//=============================================================================
void SALOME_Session_i::GetInterface()
{
- _GUIMutex->lock() ; // get access to boolean _isGUI
- //_isGUI = _IAPPThread->running();
- if(!_isGUI)
- {
- _isGUI = TRUE ;
- //_IAPPThread->start() ;
- }
- _GUIMutex->unlock() ; // release access to boolean _isGUI
+ if( !QAD_Application::getDesktop() ) {
+ _GUILauncher->wakeAll();
+ MESSAGE("SALOME_Session_i::GetInterface() called, starting GUI...")
+ }
}
//=============================================================================
* Kills the session if there are no active studies nore GUI
*/
//=============================================================================
+class CloseEvent : public SALOME_Event
+{
+public:
+ virtual void Execute() {
+ if ( QAD_Application::getDesktop() )
+ QAD_Application::getDesktop()->closeDesktop( true );
+ }
+};
void SALOME_Session_i::StopSession()
{
- qApp->lock();
- QAD_Application::getDesktop()->closeDesktop( true );
- qApp->unlock();
+ ProcessVoidEvent( new CloseEvent() );
}
//=============================================================================
*/
//=============================================================================
+class QtLock
+{
+public:
+ QtLock() { if ( qApp ) qApp->lock(); }
+ ~QtLock() { if ( qApp ) qApp->unlock(); }
+};
+
+
SALOME::StatSession SALOME_Session_i::GetStatSession()
{
// update Session state
- //qApp->lock(); // rollback bug
_GUIMutex->lock();
- //_isGUI = _IAPPThread->running();
- _isGUI = 1;
+
_runningStudies = 0;
- if (_isGUI)
- {
- qApp->lock();
- if ( QAD_Application::getDesktop() && QAD_Application::getDesktop()->getActiveApp() )
- _runningStudies = QAD_Application::getDesktop()->getActiveApp()->getStudies().count();
- qApp->unlock();
- }
+ {
+ QtLock lock;
+ _isGUI = QAD_Application::getDesktop();
+ if ( _isGUI && QAD_Application::getDesktop()->getActiveApp() )
+ _runningStudies = QAD_Application::getDesktop()->getActiveApp()->getStudies().count();
+ }
+
_GUIMutex->unlock();
- //qApp->unlock();
+
// getting stat info
SALOME::StatSession_var myStats = new SALOME::StatSession ;
if (_runningStudies)
return myStats._retn() ;
}
+CORBA::Long SALOME_Session_i::GetActiveStudyId()
+{
+ long aStudyId=-1;
+ if( QAD_Application::getDesktop() && QAD_Application::getDesktop()->getActiveStudy()) {
+ aStudyId = QAD_Application::getDesktop()->getActiveStudy()->getStudyId();
+ }
+ return aStudyId;
+}