From: vsv Date: Thu, 22 Oct 2015 14:56:27 +0000 (+0300) Subject: Set Change color as a concurrent operation which has to be done in transaction X-Git-Tag: V_2.0.0_alfa1~71 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=45df49ff011166c1f313aad07a0e39fb7c3c08eb;p=modules%2Fshaper.git Set Change color as a concurrent operation which has to be done in transaction --- 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(); }