X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FSTD%2FSTD_Application.cxx;h=ff308b7d78cb620f6f5186a717cef3b1fe4d3fc2;hb=523d074f45ba40fcf59d97e0cb813876659590c1;hp=51354196a3206ef9b134cf0a9dca08ab68e1e18e;hpb=541d3637fed062228c2ae0b2224ea698a3114cc5;p=modules%2Fgui.git diff --git a/src/STD/STD_Application.cxx b/src/STD/STD_Application.cxx index 51354196a..ff308b7d7 100755 --- a/src/STD/STD_Application.cxx +++ b/src/STD/STD_Application.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -111,7 +111,7 @@ void STD_Application::closeApplication() beforeCloseDoc( study ); study->closeDocument(); - + emit appClosed(); setActiveStudy( 0 ); delete study; @@ -321,9 +321,12 @@ void STD_Application::onOpenDoc() onOpenDoc( aName ); } -/*! \retval true, if document was opened successful, else false.*/ +/*! \retval \c true, if document was opened successful, else \c false.*/ bool STD_Application::onOpenDoc( const QString& aName ) { + if ( !abortAllOperations() ) + return false; + QApplication::setOverrideCursor( Qt::WaitCursor ); bool res = openAction( openChoice( aName ), aName ); @@ -356,8 +359,6 @@ bool STD_Application::onReopenDoc() // update views / windows / status bar / title clearViewManagers(); setActiveStudy( 0 ); - updateDesktopTitle(); - updateCommandsStatus(); // delete study delete study; @@ -366,13 +367,21 @@ bool STD_Application::onReopenDoc() // post closing actions afterCloseDoc(); + int aNbStudies = 0; + QList apps = SUIT_Session::session()->applications(); + for ( int i = 0; i < apps.count(); i++ ) + aNbStudies += apps.at( i )->getNbStudies(); + // reload study from the file res = useFile( studyName ) && activeStudy(); // if reloading is failed, close the desktop - if ( !res ) { - setDesktop( 0 ); + if ( aNbStudies && !res ) closeApplication(); + else + { + updateDesktopTitle(); + updateCommandsStatus(); } } return res; @@ -409,6 +418,8 @@ bool STD_Application::closeDoc( bool ask ) bool STD_Application::closeActiveDoc( bool permanently ) { SUIT_Study* study = activeStudy(); + if ( !study ) // no active study + return true; beforeCloseDoc( study ); @@ -446,7 +457,7 @@ bool STD_Application::closeActiveDoc( bool permanently ) } /*!Check the application on closing. - * \retval true if possible, else false + * \retval \c true if possible, else \c false */ bool STD_Application::isPossibleToClose( bool& closePermanently ) { @@ -556,6 +567,9 @@ void STD_Application::onSaveDoc() if ( !activeStudy() ) return; + if ( !abortAllOperations() ) + return; + bool isOk = false; if ( activeStudy()->isSaved() ) { @@ -584,13 +598,16 @@ void STD_Application::onSaveDoc() onSaveAsDoc(); } -/*! \retval TRUE, if doument saved successful, else FALSE.*/ +/*! \retval \c true, if document saved successfully, else \c false.*/ bool STD_Application::onSaveAsDoc() { SUIT_Study* study = activeStudy(); if ( !study ) return false; + if ( !abortAllOperations() ) + return false; + bool isOk = false; while ( !isOk ) { @@ -652,7 +669,7 @@ void STD_Application::setEditEnabled( bool theEnable ) } } -/*!\retval true, if document opened successful, else false.*/ +/*!\retval \c true, if document opened successfully, else \c false.*/ bool STD_Application::useFile(const QString& theFileName) { bool res = SUIT_Application::useFile( theFileName ); @@ -802,7 +819,7 @@ void STD_Application::clearViewManagers() } } -/*!\retval TRUE, if view manager \a vm, already in view manager list (\a myViewMgrs).*/ +/*!\retval \c true, if view manager \a vm, already in view manager list (\a myViewMgrs).*/ bool STD_Application::containsViewManager( SUIT_ViewManager* vm ) const { return myViewMgrs.contains( vm ); @@ -814,7 +831,7 @@ void STD_Application::onViewManagerActivated( SUIT_ViewManager* vm ) setActiveViewManager( vm ); } -/*!Sets status bar show, if \on = true, else status bar hide.*/ +/*!Shows status bar, if on is \c true, else hides status bar.*/ void STD_Application::onViewStatusBar( bool on ) { if ( on ) @@ -1005,3 +1022,11 @@ int STD_Application::viewManagerId( const SUIT_ViewManager* theManager) const return myViewMgrs.indexOf(const_cast(theManager)); } +/*! + \brief Abort active operations if there are any + \return \c false if some operation cannot be aborted +*/ +bool STD_Application::abortAllOperations() +{ + return true; +}