//}
}*/
+namespace
+{
+ /*!
+ \brief Flag locker.
+ */
+ class MessageLocker
+ {
+ public:
+ //! Constructor. Sets passed boolean flag to \c true.
+ MessageLocker( bool& Lock ) : myPrevState( Lock ), myLock( Lock ) { myLock = true; }
+ //! Destructor. Clear external boolean flag passed as parameter to the constructor to \c false.
+ ~MessageLocker() { myLock = myPrevState; }
+ private:
+ bool myPrevState;
+ bool& myLock; //! External 'Lock state' boolean flag
+ };
+}
+
/*!Create new instance of SalomeApp_Application.*/
extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication()
{
/*!Constructor.*/
SalomeApp_Application::SalomeApp_Application()
: LightApp_Application(),
- myIsCloseFromExit( false )
+ myIsCloseFromExit( false ),
+ myToIgnoreMessages( false )
{
}
*/
void SalomeApp_Application::onExit()
{
+ //MessageLocker ml( myToIgnoreMessages );
+
bool killServers = false;
bool result = true;
}
}
+/*!SLOT. Create a document.*/
+void SalomeApp_Application::onNewDoc()
+{
+ MessageLocker ml( myToIgnoreMessages );
+
+ LightApp_Application::onNewDoc();
+}
+
/*!SLOT. Load document.*/
void SalomeApp_Application::onLoadDoc()
{
+ MessageLocker ml( myToIgnoreMessages );
+
QString studyName;
// rnv: According to the single-study approach on the server side
/*!SLOT. Parse message for desktop.*/
void SalomeApp_Application::onDesktopMessage( const QString& message )
{
+ if ( myToIgnoreMessages )
+ return; // a message from SALOMEDS is caused by GUI action
+
+ MessageLocker ml( myToIgnoreMessages );
+
if (message.indexOf("studyCreated") == 0) {
if (!activeStudy()) {
onNewDoc();
}
}
else if ( message.toLower() == "connect_to_study" ) {
- onLoadDoc();
+ if ( activeStudy() )
+ useStudy( activeStudy()->studyName() );
}
if (message.indexOf("studyNameChanged") == 0) {
updateDesktopTitle();
SUIT_MessageBox::No) == SUIT_MessageBox::No ) return;
}
+ MessageLocker ml( myToIgnoreMessages );
+
LightApp_Application::onCloseDoc( ask );
// reinitialize study to have empty data
- getStudy()->Init();
+ //getStudy()->Init();
+}
+
+/*!SLOT. Reload document from the file.*/
+bool SalomeApp_Application::onReopenDoc()
+{
+ MessageLocker ml( myToIgnoreMessages );
+
+ return LightApp_Application::onReopenDoc();
+}
+
+
+/*!SLOT. Load document.*/
+void SalomeApp_Application::onOpenDoc()
+{
+ MessageLocker ml( myToIgnoreMessages );
+
+ LightApp_Application::onOpenDoc();
+}
+
+/*!SLOT. Load document.*/
+bool SalomeApp_Application::onOpenDoc(const QString& name)
+{
+ MessageLocker ml( myToIgnoreMessages );
+
+ return LightApp_Application::onOpenDoc(name);
}
/*!Sets enable or disable some actions on selection changed.*/
this, SIGNAL(notebookVarUpdated(QString)) );
#endif
+ getStudy()->Init();
+
return aStudy;
}