From: eap Date: Wed, 29 Aug 2018 13:21:31 +0000 (+0300) Subject: Replace Close operation by New X-Git-Tag: SHAPER_V9_1_0RC1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=579fbe293197d8a2e2a1a436abf15ceeca1dacb3;p=modules%2Fgui.git Replace Close operation by New (STD_Application) + Disable call-backs from SALOMEDS on opeartions invoked in GUI (SalomeApp_Application) + Fix reading a just deleted myRoot in updateObjectBrowser() (SalomeApp_Study) --- diff --git a/src/STD/STD_Application.cxx b/src/STD/STD_Application.cxx index e724096c5..9edb2b919 100755 --- a/src/STD/STD_Application.cxx +++ b/src/STD/STD_Application.cxx @@ -157,8 +157,6 @@ void STD_Application::createActions() resMgr->loadPixmap( "STD", tr( "ICON_FILE_NEW" ) ), tr( "MEN_DESK_FILE_NEW" ), tr( "PRP_DESK_FILE_NEW" ), Qt::CTRL+Qt::Key_N, desk, false, this, SLOT( onNewDoc() ) ); - //no need at this action for mono-study application because study is always exists - action( FileNewId )->setVisible( false ); createAction( FileOpenId, tr( "TOT_DESK_FILE_OPEN" ), resMgr->loadPixmap( "STD", tr( "ICON_FILE_OPEN" ) ), @@ -173,6 +171,8 @@ void STD_Application::createActions() resMgr->loadPixmap( "STD", tr( "ICON_FILE_CLOSE" ) ), tr( "MEN_DESK_FILE_CLOSE" ), tr( "PRP_DESK_FILE_CLOSE" ), Qt::CTRL+Qt::Key_W, desk, false, this, SLOT( onCloseDoc() ) ); + //no need in this action for mono-study application as it is same as NewDoc + action( FileCloseId )->setVisible( false ); createAction( FileExitId, tr( "TOT_DESK_FILE_EXIT" ), QIcon(), tr( "MEN_DESK_FILE_EXIT" ), tr( "PRP_DESK_FILE_EXIT" ), @@ -257,7 +257,7 @@ void STD_Application::createActions() // Create tool bars int stdTBar = createTool( tr( "INF_DESK_TOOLBAR_STANDARD" ), // title (language-dependant) - QString( "SalomeStandard" ) ); // name (language-independant) + QString( "SalomeStandard" ) ); // name (language-independant) // Create tool items @@ -742,7 +742,7 @@ int STD_Application::showNotification(const QString& message, const QString& tit { SUIT_ResourceMgr* aResMgr = resourceMgr(); if (aResMgr) - delay = aResMgr->integerValue("notification", "timeout", 0) * 1000; + delay = aResMgr->integerValue("notification", "timeout", 0) * 1000; } uid = ntfMgr->showNotification(message, title, qMax(delay, 0)); } diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 635bb2bbb..caac68017 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -155,6 +155,24 @@ void SalomeApp_Updater::update( SUIT_DataObject* theObj, OB_ListItem* theItem ) //} }*/ +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() { @@ -164,7 +182,8 @@ extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication() /*!Constructor.*/ SalomeApp_Application::SalomeApp_Application() : LightApp_Application(), - myIsCloseFromExit( false ) + myIsCloseFromExit( false ), + myToIgnoreMessages( false ) { } @@ -382,6 +401,8 @@ void SalomeApp_Application::createActions() */ void SalomeApp_Application::onExit() { + //MessageLocker ml( myToIgnoreMessages ); + bool killServers = false; bool result = true; @@ -398,9 +419,19 @@ void SalomeApp_Application::onExit() } } +/*!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 @@ -549,6 +580,11 @@ bool SalomeApp_Application::onLoadDoc( const QString& aName ) /*!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(); @@ -566,7 +602,8 @@ void SalomeApp_Application::onDesktopMessage( const QString& message ) } } else if ( message.toLower() == "connect_to_study" ) { - onLoadDoc(); + if ( activeStudy() ) + useStudy( activeStudy()->studyName() ); } if (message.indexOf("studyNameChanged") == 0) { updateDesktopTitle(); @@ -672,10 +709,37 @@ void SalomeApp_Application::onCloseDoc( bool ask ) 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.*/ @@ -775,6 +839,8 @@ SUIT_Study* SalomeApp_Application::createNewStudy() this, SIGNAL(notebookVarUpdated(QString)) ); #endif + getStudy()->Init(); + return aStudy; } diff --git a/src/SalomeApp/SalomeApp_Application.h b/src/SalomeApp/SalomeApp_Application.h index cf112abbf..b7dffc9f5 100644 --- a/src/SalomeApp/SalomeApp_Application.h +++ b/src/SalomeApp/SalomeApp_Application.h @@ -117,11 +117,15 @@ public: virtual bool renameObject( const QString&, const QString& ); public slots: + virtual void onNewDoc(); virtual void onLoadDoc(); virtual void onNewWithScript(); virtual bool onLoadDoc( const QString& ); virtual void onUnloadDoc( bool ask = true); virtual void onCloseDoc( bool ask = true); + virtual void onOpenDoc(); + virtual bool onOpenDoc( const QString& ); + virtual bool onReopenDoc(); virtual void onExit(); virtual void onCopy(); @@ -196,6 +200,8 @@ private: QMap myExtActions; // Map bool myIsCloseFromExit; // "Close from Exit" flag + bool myToIgnoreMessages;// to ignore messages from SALOMEDS + signals: void dumpedStudyClosed( const QString& theDumpScript, const QString& theStudyName, diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index a7db412c7..55a90abe7 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -413,6 +413,7 @@ SalomeApp_Study::~SalomeApp_Study() if ( myObserver ) { PortableServer::ObjectId_var oid = myObserver->_default_POA()->servant_to_id( myObserver ); myObserver->_default_POA()->deactivate_object( oid.in() ); + myObserver = 0; } } @@ -571,6 +572,13 @@ bool SalomeApp_Study::loadDocument( const QString& theStudyName ) while ( it.hasNext() ) openDataModel( studyName(), it.next() ); + bool res = CAM_Study::openDocument( theStudyName ); + + //rnv: to fix the "0051779: TC7.2.0: Save operation works incorrectly for study loaded from data server" + // mark study as "not saved" after call openDocument( ... ) method. + setIsSaved(false); + emit opened( this ); // myRoot is set to Object Browser here + // this will build a SUIT_DataObject-s tree under myRoot member field // passing "false" in order NOT to rebuild existing data models' trees - it was done in previous step // but tree that corresponds to not-loaded data models will be updated any way. @@ -583,13 +591,6 @@ bool SalomeApp_Study::loadDocument( const QString& theStudyName ) myStudyDS->attach(myObserver->_this(),true); #endif - bool res = CAM_Study::openDocument( theStudyName ); - - //rnv: to fix the "0051779: TC7.2.0: Save operation works incorrectly for study loaded from data server" - // mark study as "not saved" after call openDocument( ... ) method. - setIsSaved(false); - emit opened( this ); - bool restore = application()->resourceMgr()->booleanValue( "Study", "store_visual_state", true ); if ( restore ) { std::vector savePoints = getSavePoints();