From 00a3c1675ca0ead43040cafa3a99f984e1d8177b Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 8 Dec 2017 15:43:41 +0300 Subject: [PATCH] Issue #2344: Fix cleared selection on Cancel of Undo/Redo command --- src/XGUI/XGUI_Workshop.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 495ecfc29..dc5a12f43 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1030,15 +1030,19 @@ void XGUI_Workshop::onUndo(int theTimes) return; } - objectBrowser()->treeView()->setCurrentIndex(QModelIndex()); SessionPtr aMgr = ModelAPI_Session::get(); - std::list 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 aUndoList = aMgr->undoList(); std::list::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 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 aRedoList = aMgr->redoList(); std::list::const_iterator aIt = aRedoList.cbegin(); for (int i = 0; (i < theTimes) && (aIt != aRedoList.cend()); ++i, ++aIt) { aMgr->redo(); -- 2.39.2