X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_Update.cpp;h=659b7ca9a2764290a121241f5f7ea5da83cba458;hb=b857d9ea753bef79dbbadaeb990b54aae56e488d;hp=f86c3076b240ecde193a2eb4955552fbbed23100;hpb=c4eab94a20a0d93100549a210582d46409fec1cc;p=modules%2Fshaper.git diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index f86c3076b..659b7ca9a 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// Copyright (C) 2014-2020 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -202,11 +202,11 @@ bool Model_Update::addModified(FeaturePtr theFeature, FeaturePtr theReason) { ModelAPI_Tools::allResults(theFeature, allResults); std::list::iterator aRes = allResults.begin(); for(; aRes != allResults.end(); aRes++) { - const std::set >& aRefs = (*aRes)->data()->refsToMe(); - std::set >::const_iterator aRefIter = aRefs.cbegin(); - for(; aRefIter != aRefs.cend(); aRefIter++) { - if ((*aRefIter)->isArgument()) { - FeaturePtr aReferenced = std::dynamic_pointer_cast((*aRefIter)->owner()); + const std::set >& aResRefs = (*aRes)->data()->refsToMe(); + std::set >::const_iterator aRIter = aResRefs.cbegin(); + for(; aRIter != aResRefs.cend(); aRIter++) { + if ((*aRIter)->isArgument()) { + FeaturePtr aReferenced = std::dynamic_pointer_cast((*aRIter)->owner()); if (aReferenced.get()) { addModified(aReferenced, theFeature); } @@ -227,7 +227,7 @@ bool Model_Update::addModified(FeaturePtr theFeature, FeaturePtr theReason) { void Model_Update::processEvent(const std::shared_ptr& theMessage) { static Events_Loop* aLoop = Events_Loop::loop(); - static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators(); + //static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators(); static const Events_ID kCreatedEvent = aLoop->eventByName(EVENT_OBJECT_CREATED); static const Events_ID kUpdatedEvent = aLoop->eventByName(EVENT_OBJECT_UPDATED); static const Events_ID kOpFinishEvent = aLoop->eventByName("FinishOperation"); @@ -265,7 +265,7 @@ void Model_Update::processEvent(const std::shared_ptr& theMessag } } processFeatures(); - myIsPreviewBlocked = myIsPreviewBlocked; + myIsPreviewBlocked = aPreviewBlockedState; } } @@ -360,7 +360,7 @@ void Model_Update::processEvent(const std::shared_ptr& theMessag for(; aRefIter != aRefs.cend(); aRefIter++) { if (!(*aRefIter)->owner()->data()->isValid()) continue; - FeaturePtr anUpdated = std::dynamic_pointer_cast((*aRefIter)->owner()); + anUpdated = std::dynamic_pointer_cast((*aRefIter)->owner()); if (anUpdated.get()) { if (addModified(anUpdated, aReason)) aSomeModified = true; @@ -441,7 +441,7 @@ void Model_Update::processEvent(const std::shared_ptr& theMessag Events_Loop::loop()->flush(kRedisplayEvent); // in the end of transaction everything is updated, so clear the old objects - myIsParamUpdated = false; + //myIsParamUpdated = false; // to avoid problems in sprocket.py parameter update myWaitForFinish.clear(); } else if (theMessage->eventID() == kReorderEvent) { std::shared_ptr aMsg = @@ -535,9 +535,21 @@ bool Model_Update::processFeature(FeaturePtr theFeature) return false; } + // check this feature is not yet checked or processed + bool aIsModified = myModified.find(theFeature) != myModified.end(); + if (!aIsModified && myIsFinish) { // get info about the modification for features without preview + if (theFeature->data()->execState() == ModelAPI_StateMustBeUpdated) { + aIsModified = true; + std::set > aNewSet; + // contains itself, so, we don't know which was the reason and the reason is any + aNewSet.insert(theFeature); + myModified[theFeature] = aNewSet; + } + } + if (myProcessed.find(theFeature) == myProcessed.end()) { myProcessed[theFeature] = 0; - } else { + } else if (aIsModified) { int aCount = myProcessed[theFeature]; if (aCount > 100) { // too many repetition of processing (in VS it may crash on 330 with stack overflow) @@ -550,18 +562,6 @@ bool Model_Update::processFeature(FeaturePtr theFeature) myProcessed[theFeature] = aCount + 1; } - // check this feature is not yet checked or processed - bool aIsModified = myModified.find(theFeature) != myModified.end(); - if (!aIsModified && myIsFinish) { // get info about the modification for features without preview - if (theFeature->data()->execState() == ModelAPI_StateMustBeUpdated) { - aIsModified = true; - std::set > aNewSet; - // contains itself, so, we don't know which was the reason and the reason is any - aNewSet.insert(theFeature); - myModified[theFeature] = aNewSet; - } - } - #ifdef DEB_UPDATE std::cout<<"* Process feature "<name()<isStable()) { aDoExecute = true; - } else if (theFeature->results().size()) { // execute only not-results features - aDoExecute = !(theFeature->firstResult()->groupName() == ModelAPI_ResultBody::group() || - theFeature->firstResult()->groupName() == ModelAPI_ResultPart::group() || - theFeature->getKind() == "Sketch"); + } else if (theFeature->results().size()) { // execute only not persistent results features + aDoExecute = !theFeature->isPersistentResult(); } else { aDoExecute = aState != ModelAPI_StateInvalidArgument; } @@ -908,6 +911,10 @@ void Model_Update::updateArguments(FeaturePtr theFeature) { for (aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) { std::shared_ptr aSel = std::dynamic_pointer_cast(*aRefsIter); + // #19071 : avoid sending of update event in cycle + bool aWasBlocked = theFeature->data()->blockSendAttributeUpdated(true); + // list to keep the shared pointers while update is blocked (in messages raw poiters are used) + std::list anAttrList; for(int a = aSel->size() - 1; a >= 0; a--) { std::shared_ptr aSelAttr = std::dynamic_pointer_cast(aSel->value(a)); @@ -916,6 +923,7 @@ void Model_Update::updateArguments(FeaturePtr theFeature) { // update argument only if the referenced object is ready to use if (aContext.get() && !aContext->isDisabled()) { if (isReason(theFeature, aContext)) { + anAttrList.push_back(aSelAttr); if (!aSelAttr->update()) { bool isObligatory = !aFactory->isNotObligatory( theFeature->getKind(), theFeature->data()->id(aSel)) && @@ -932,6 +940,8 @@ void Model_Update::updateArguments(FeaturePtr theFeature) { } } } + if (!aWasBlocked) + theFeature->data()->blockSendAttributeUpdated(false); } if (aState != ModelAPI_StateDone)