From: sbh Date: Thu, 11 Sep 2014 15:36:00 +0000 (+0400) Subject: Issue #87 abort active operations on save/open X-Git-Tag: V_0.4.4~70 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=02a847d88db188c0ca5d0c9a77a4584034c7d70d;p=modules%2Fshaper.git Issue #87 abort active operations on save/open --- diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index aa836f4cf..9b2902ecb 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -141,9 +141,10 @@ bool XGUI_OperationMgr::canStopOperation() if (anOperation->isModified()) { int anAnswer = QMessageBox::question( qApp->activeWindow(), tr("Operation launch"), - tr("Previous operation is not finished and will be aborted"), QMessageBox::Ok, + tr("Previous operation is not finished, abort it?"), + QMessageBox::Abort | QMessageBox::Cancel, QMessageBox::Cancel); - return anAnswer == QMessageBox::Ok; + return anAnswer == QMessageBox::Abort; } } return true; diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 1c9277eaa..916ad1550 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -577,9 +577,11 @@ void XGUI_Workshop::onNew() //****************************************************** void XGUI_Workshop::onOpen() { + if(!myOperationMgr->abortOperation()) + return; //save current file before close if modified - SessionPtr aMgr = ModelAPI_Session::get(); - if (aMgr->isModified()) { + SessionPtr aSession = ModelAPI_Session::get(); + if (aSession->isModified()) { //TODO(sbh): re-launch the app? int anAnswer = QMessageBox::question( myMainWindow, tr("Save current file"), @@ -590,7 +592,7 @@ void XGUI_Workshop::onOpen() } else if (anAnswer == QMessageBox::Cancel) { return; } - aMgr->moduleDocument()->close(); + aSession->moduleDocument()->close(); myCurrentDir = ""; } @@ -605,7 +607,7 @@ void XGUI_Workshop::onOpen() return; } QApplication::setOverrideCursor(Qt::WaitCursor); - aMgr->load(myCurrentDir.toLatin1().constData()); + aSession->load(myCurrentDir.toLatin1().constData()); myObjectBrowser->rebuildDataTree(); displayAllResults(); updateCommandStatus(); @@ -615,6 +617,8 @@ void XGUI_Workshop::onOpen() //****************************************************** bool XGUI_Workshop::onSave() { + if(!myOperationMgr->abortOperation()) + return false; if (myCurrentDir.isEmpty()) { return onSaveAs(); } @@ -628,6 +632,8 @@ bool XGUI_Workshop::onSave() //****************************************************** bool XGUI_Workshop::onSaveAs() { + if(!myOperationMgr->abortOperation()) + return false; QFileDialog dialog(mainWindow()); dialog.setWindowTitle(tr("Select directory to save files...")); dialog.setFileMode(QFileDialog::Directory);