From 45df49ff011166c1f313aad07a0e39fb7c3c08eb Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 22 Oct 2015 17:56:27 +0300 Subject: [PATCH] Set Change color as a concurrent operation which has to be done in transaction --- src/XGUI/XGUI_Workshop.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 184cafe05..6a988677a 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1503,6 +1503,7 @@ void setColor(ResultPtr theResult, const std::vector& theColor) //************************************************************** void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects) { + AttributeIntArrayPtr aColorAttr; // 1. find the current color of the object. This is a color of AIS presentation // The objects are iterated until a first valid color is found @@ -1529,6 +1530,8 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects) if (aColor.size() != 3) return; + if (!abortAllOperations()) + return; // 2. show the dialog to change the value XGUI_ColorDialog* aDlg = new XGUI_ColorDialog(mainWindow()); aDlg->setColor(aColor); @@ -1541,11 +1544,8 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects) // 3. abort the previous operation and start a new one SessionPtr aMgr = ModelAPI_Session::get(); - bool aWasOperation = aMgr->isOperation(); // keep this value - if (!aWasOperation) { - QString aDescription = contextMenuMgr()->action("COLOR_CMD")->text(); - aMgr->startOperation(aDescription.toStdString()); - } + QString aDescription = contextMenuMgr()->action("COLOR_CMD")->text(); + aMgr->startOperation(aDescription.toStdString()); // 4. set the value to all results std::vector aColorResult = aDlg->getColor(); @@ -1561,8 +1561,7 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects) setColor(aResult, !isRandomColor ? aColorResult : aDlg->getRandomColor()); } } - if (!aWasOperation) - aMgr->finishOperation(); + aMgr->finishOperation(); updateCommandStatus(); } -- 2.39.2