]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2344: Fix cleared selection on Cancel of Undo/Redo command
authorvsv <vsv@opencascade.com>
Fri, 8 Dec 2017 12:43:41 +0000 (15:43 +0300)
committervsv <vsv@opencascade.com>
Fri, 8 Dec 2017 12:43:41 +0000 (15:43 +0300)
src/XGUI/XGUI_Workshop.cpp

index 495ecfc29005968f092e473a11e34002e99d46d3..dc5a12f4301c327670e6e1be466b98828480c9c3 100755 (executable)
@@ -1030,15 +1030,19 @@ void XGUI_Workshop::onUndo(int theTimes)
       return;
   }
 
-  objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
   SessionPtr aMgr = ModelAPI_Session::get();
-  std::list<std::string> aUndoList = aMgr->undoList();
   if (aMgr->isOperation()) {
+    XGUI_OperationMgr* aOpMgr = operationMgr();
     /// this is important for nested operations
     /// when sketch operation is active, this condition is false and
     /// the sketch operation is not aborted
-    operationMgr()->onAbortOperation();
+    if (aOpMgr->canStopOperation(aOpMgr->currentOperation()))
+      aOpMgr->abortOperation(aOpMgr->currentOperation());
+    else
+      return;
   }
+  objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
+  std::list<std::string> aUndoList = aMgr->undoList();
   std::list<std::string>::const_iterator aIt = aUndoList.cbegin();
   for (int i = 0; (i < theTimes) && (aIt != aUndoList.cend()); ++i, ++aIt) {
     aMgr->undo();
@@ -1067,15 +1071,19 @@ void XGUI_Workshop::onRedo(int theTimes)
   // until redo of all possible objects happens
   bool isUpdateEnabled = myDisplayer->enableUpdateViewer(false);
 
-  objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
   SessionPtr aMgr = ModelAPI_Session::get();
-  std::list<std::string> aRedoList = aMgr->redoList();
   if (aMgr->isOperation()) {
+    XGUI_OperationMgr* aOpMgr = operationMgr();
     /// this is important for nested operations
     /// when sketch operation is active, this condition is false and
     /// the sketch operation is not aborted
-    operationMgr()->onAbortOperation();
+    if (aOpMgr->canStopOperation(aOpMgr->currentOperation()))
+      aOpMgr->abortOperation(aOpMgr->currentOperation());
+    else
+      return;
   }
+  objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
+  std::list<std::string> aRedoList = aMgr->redoList();
   std::list<std::string>::const_iterator aIt = aRedoList.cbegin();
   for (int i = 0; (i < theTimes) && (aIt != aRedoList.cend()); ++i, ++aIt) {
     aMgr->redo();