From 996183a4513792341ab2452517b89d9ef8b7bb4c Mon Sep 17 00:00:00 2001 From: mpv Date: Tue, 26 Apr 2016 17:21:54 +0300 Subject: [PATCH] Fix for the issue #1457 --- src/Model/Model_Document.cpp | 2 -- src/ModelAPI/ModelAPI_Document.h | 3 ++- src/XGUI/XGUI_OperationMgr.cpp | 11 ++++++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 072b07d71..2626bf770 100755 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -976,8 +976,6 @@ void Model_Document::setCurrentFeature( } // make all features after this feature disabled in reversed order (to remove results without deps) static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY); - static Events_ID aCreateEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED); - static Events_ID aDeleteEvent = aLoop->eventByName(EVENT_OBJECT_DELETED); bool aPassed = false; // flag that the current object is already passed in cycle FeaturePtr anIter = myObjs->lastFeature(); diff --git a/src/ModelAPI/ModelAPI_Document.h b/src/ModelAPI/ModelAPI_Document.h index 6fe1c9121..cd13996dc 100644 --- a/src/ModelAPI/ModelAPI_Document.h +++ b/src/ModelAPI/ModelAPI_Document.h @@ -98,7 +98,8 @@ public: virtual std::shared_ptr currentFeature(const bool theVisible) = 0; //! Sets the current feature: all features below will be disabled, new features - //! will be appended after this one. + //! will be appended after this one. This method does not flushes the events appeared: + //! it will be done by the finishOperation, or direct flushes //! \param theCurrent the selected feature as current: blow it everythin become disabled //! \param theVisible use visible features only: flag is true for Object Browser functionality virtual void setCurrentFeature(std::shared_ptr theCurrent, diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 814d0b454..7b1a4e14d 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -444,9 +444,18 @@ void XGUI_OperationMgr::onBeforeOperationStarted() ModuleBase_Tools::objectInfo(ModelAPI_Session::get()->activeDocument()->currentFeature(false))).toStdString().c_str()); #endif - if (aFOperation->isEditOperation()) // it should be performed by the feature edit only + if (aFOperation->isEditOperation()) {// it should be performed by the feature edit only // in create operation, the current feature is changed by addFeature() aDoc->setCurrentFeature(aFOperation->feature(), false); + // this is the only place where flushes must be called after setCurrentFeature for the current + // moment: after this the opertion is not finished, so, the ObjectBrowser state may be corrupted + // (issue #1457) + static Events_Loop* aLoop = Events_Loop::loop(); + static Events_ID aCreateEvent = aLoop->eventByName(EVENT_OBJECT_CREATED); + aLoop->flush(aCreateEvent); + static Events_ID aDeleteEvent = aLoop->eventByName(EVENT_OBJECT_DELETED); + aLoop->flush(aDeleteEvent); + } #ifdef DEBUG_CURRENT_FEATURE qDebug("\tdocument->setCurrentFeature"); -- 2.39.2