/*!Closing session.*/
void STD_Application::onExit()
{
- int aAnswer = SUIT_MessageBox::info2( desktop(), tr( "INF_DESK_EXIT" ), tr( "QUE_DESK_EXIT" ),
- tr( "BUT_OK" ), tr( "BUT_CANCEL" ), 1, 2, 2 );
- if ( aAnswer == 1 )
+ STD_ExitDlg* dlg = new STD_ExitDlg(desktop());
+ if( dlg->exec() == QDialog::Accepted ) {
+ SUIT_Session::session()->serversShutdown(dlg->isServersShutdown());
+ delete dlg;
SUIT_Session::session()->closeSession();
+ }
}
/*!Virtual slot. Not implemented here.*/
if ( btn == m_pb3 )
done( 3 );
}
+
+/*!
+ * \brief creates a Exit dialog box
+ * \param parent a parent widget
+ * \param modal bool argument, if true the dialog box is a modal dialog box
+ * \param f style flags
+ */
+
+STD_ExitDlg::STD_ExitDlg( QWidget* parent, bool modal, WFlags f )
+: QDialog( parent, "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+{
+ setSizeGripEnabled( true );
+ setCaption( tr( "INF_DESK_EXIT" ) );
+
+ QVBoxLayout* m_vbL = new QVBoxLayout( this );
+ m_vbL->setMargin( 11 );
+ m_vbL->setSpacing( 6 );
+
+ QLabel* m_lIcon = new QLabel( this, "m_lDescr" );
+ QPixmap pm = QMessageBox::standardIcon( QMessageBox::Question );
+ m_lIcon->setPixmap( pm );
+ m_lIcon->setScaledContents( false );
+ m_lIcon->setAlignment( Qt::AlignCenter );
+
+ QLabel* m_lDescr = new QLabel (this, "m_lDescr");
+ m_lDescr->setText ( tr ("QUE_DESK_EXIT") );
+ m_lDescr->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
+
+ myServersShutdown = new QCheckBox(tr("SHUTDOWN_SERVERS"), this);
+ myServersShutdown->setChecked(true);
+
+ QVBoxLayout* m_vl1 = new QVBoxLayout();
+ m_vl1->setMargin( 10 ); m_vl1->setSpacing( 16 );
+ m_vl1->addWidget( m_lDescr );
+ m_vl1->addWidget( myServersShutdown );
+
+ QHBoxLayout* m_hl1 = new QHBoxLayout();
+ m_hl1->setMargin( 0 ); m_hl1->setSpacing( 6 );
+ m_hl1->addWidget( m_lIcon );
+ m_hl1->addStretch();
+ m_hl1->addLayout( m_vl1 );
+ m_hl1->addStretch();
+
+ QPushButton* m_pbOk = new QPushButton( tr ("BUT_OK"), this );
+ QPushButton* m_pbCancel = new QPushButton( tr ("BUT_CANCEL"), this );
+
+ QGridLayout* m_hl2 = new QGridLayout();
+ m_hl2->setMargin( 0 ); m_hl2->setSpacing( 6 );
+ m_hl2->addWidget( m_pbOk, 0, 0 );
+ m_hl2->setColStretch( 1, 5 );
+ m_hl2->addWidget( m_pbCancel, 0, 2 );
+
+ m_vbL->addStretch();
+ m_vbL->addLayout( m_hl1 );
+ m_vbL->addStretch();
+ m_vbL->addLayout( m_hl2 );
+
+ connect( m_pbOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
+ connect( m_pbCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
+}
+
+/*!
+ * \brief get the check box status
+ */
+bool STD_ExitDlg::isServersShutdown()
+{
+ return myServersShutdown->isChecked();
+}
+
#define STD_CloseDlg_H
#include <qdialog.h>
+#include <qcheckbox.h>
/*! \class QDialog
* \brief For more information see <a href="http://doc.trolltech.com">QT documentation</a>.
QPushButton* m_pb4;
};
+/*!\class STD_ExitDlg
+ * \brief Describes a dialog box shown on question about quit application
+ */
+class STD_ExitDlg: public QDialog
+{
+ Q_OBJECT
+
+public:
+ STD_ExitDlg ( QWidget * parent = 0, bool modal = FALSE, WFlags f = 0 ) ;
+ ~STD_ExitDlg ( ) { };
+
+ bool isServersShutdown();
+
+private:
+ QCheckBox* myServersShutdown;
+
+};
+
#endif
#include "SALOME_NamingService.hxx"
#include "SALOMETraceCollector.hxx"
+#include "SALOME_ModuleCatalog_impl.hxx"
+#include "OpUtil.hxx"
+#include "RegistryService.hxx"
+#include "ConnectionManager_i.hxx"
+
#include <iostream>
#ifndef WNT
#include <unistd.h>
return false;
}
+// shutdown standalone servers
+void shutdownServers( SALOME_NamingService* theNS )
+{
+ // get each Container from NamingService => shutdown it
+ // (the order is inverse to the order of servers initialization)
+
+ CORBA::Object_var objS = theNS->Resolve("/Kernel/Session");
+ SALOME::Session_var session = SALOME::Session::_narrow(objS);
+ if (!CORBA::is_nil(session)) {
+ session->ping();
+
+ string hostname = GetHostname();
+ string containerName = "/Containers/" + hostname;
+
+ // 1) SuperVisionContainer
+ string containerNameSV = containerName + "/SuperVisionContainer";
+ CORBA::Object_var objSV = theNS->Resolve(containerNameSV.c_str());
+ Engines::Container_var SVcontainer = Engines::Container::_narrow(objSV) ;
+ if ( !CORBA::is_nil(SVcontainer) && ( session->getPID() != SVcontainer->getPID() ) )
+ SVcontainer->Shutdown();
+
+ // 2) FactoryServerPy
+ string containerNameFSP = containerName + "/FactoryServerPy";
+ CORBA::Object_var objFSP = theNS->Resolve(containerNameFSP.c_str());
+ Engines::Container_var FSPcontainer = Engines::Container::_narrow(objFSP) ;
+ if ( !CORBA::is_nil(FSPcontainer) && ( session->getPID() != FSPcontainer->getPID() ) )
+ FSPcontainer->Shutdown();
+
+ // 3) FactoryServer
+ string containerNameFS = containerName + "/FactoryServer";
+ CORBA::Object_var objFS = theNS->Resolve(containerNameFS.c_str());
+ Engines::Container_var FScontainer = Engines::Container::_narrow(objFS) ;
+ if ( !CORBA::is_nil(FScontainer) && ( session->getPID() != FScontainer->getPID() ) )
+ FScontainer->Shutdown();
+
+ // 4) ContainerManager
+ CORBA::Object_var objCM=theNS->Resolve("/ContainerManager");
+ Engines::ContainerManager_var contMan=Engines::ContainerManager::_narrow(objCM);
+ if ( !CORBA::is_nil(contMan) && ( session->getPID() != contMan->getPID() ) )
+ contMan->ShutdownWithExit();
+
+ // 5) ConnectionManager
+ CORBA::Object_var objCnM=theNS->Resolve("/ConnectionManager");
+ Engines::ConnectionManager_var connMan=Engines::ConnectionManager::_narrow(objCnM);
+ if ( !CORBA::is_nil(connMan) && ( session->getPID() != connMan->getPID() ) )
+ connMan->ShutdownWithExit();
+
+ // 6) SALOMEDS
+ CORBA::Object_var objSDS = theNS->Resolve("/myStudyManager");
+ SALOMEDS::StudyManager_var studyManager = SALOMEDS::StudyManager::_narrow(objSDS) ;
+ if ( !CORBA::is_nil(studyManager) && ( session->getPID() != studyManager->getPID() ) )
+ studyManager->ShutdownWithExit();
+
+ // 7) ModuleCatalog
+ CORBA::Object_var objMC=theNS->Resolve("/Kernel/ModulCatalog");
+ SALOME_ModuleCatalog::ModuleCatalog_var catalog = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objMC);
+ if ( !CORBA::is_nil(catalog) && ( session->getPID() != catalog->getPID() ) )
+ catalog->ShutdownWithExit();
+
+ // 8) Registry
+ CORBA::Object_var objR = theNS->Resolve("/Registry");
+ Registry::Components_var registry = Registry::Components::_narrow(objR);
+ if ( !CORBA::is_nil(registry) && ( session->getPID() != registry->getPID() ) )
+ registry->end();
+ }
+}
+
// ---------------------------- MAIN -----------------------
int main( int argc, char **argv )
{
delete splash;
splash = 0;
- if ( result == SUIT_Session::FROM_GUI ) // desktop is closed by user from GUI
+ if ( result == SUIT_Session::FROM_GUI ) { // desktop is closed by user from GUI
+ if ( aGUISession->isServersShutdown() )
+ shutdownServers( _NS );
break;
+ }
}
delete aGUISession;
CORBA::Long GetActiveStudyId();
void ping(){};
+ CORBA::Long getPID() { return (CORBA::Long)getpid(); };
//! Restors a visual state of the study at theSavePoint
bool restoreVisualState(CORBA::Long theSavePoint);