]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #87 abort active operations on save/open
authorsbh <sergey.belash@opencascade.com>
Thu, 11 Sep 2014 15:36:00 +0000 (19:36 +0400)
committersbh <sergey.belash@opencascade.com>
Thu, 11 Sep 2014 15:36:00 +0000 (19:36 +0400)
src/XGUI/XGUI_OperationMgr.cpp
src/XGUI/XGUI_Workshop.cpp

index aa836f4cf581ee939ea733150ef6030a6a9baa51..9b2902ecba69e614908d88253f97bdf88d7dbb4a 100644 (file)
@@ -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;
index 1c9277eaa584686f825eba4bfb7d913f7a173f42..916ad15500f57f1f57603a0b571a4d3f5293c89a 100644 (file)
@@ -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);