From 280ea8bb86dacc34aa86012472ec69b7cff04964 Mon Sep 17 00:00:00 2001 From: mpv Date: Mon, 10 Aug 2015 14:32:46 +0300 Subject: [PATCH] Fix for the TestParameterRename.py crash sometimes on Linux: map removes shared pointer and destructor call the map with the same key that causes the infinitive recursion. --- src/Model/Model_Objects.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 9e4e270ac..9c7a4eafa 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -59,16 +59,17 @@ Model_Objects::~Model_Objects() { // delete all features of this document Events_Loop* aLoop = Events_Loop::loop(); - NCollection_DataMap::Iterator aFeaturesIter(myFeatures); - for(; aFeaturesIter.More(); aFeaturesIter.Next()) { + // erase one by one to avoid access from the feature destructor itself from he map + while(!myFeatures.IsEmpty()) { + NCollection_DataMap::Iterator aFeaturesIter(myFeatures); FeaturePtr aFeature = aFeaturesIter.Value(); static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY); ModelAPI_EventCreator::get()->sendDeleted(myDoc, ModelAPI_Feature::group()); ModelAPI_EventCreator::get()->sendUpdated(aFeature, EVENT_DISP); aFeature->eraseResults(); aFeature->erase(); + myFeatures.UnBind(aFeaturesIter.Key()); } - myFeatures.Clear(); aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED)); aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); -- 2.39.2