From: mpv Date: Fri, 21 Dec 2018 08:06:00 +0000 (+0300) Subject: Fix for the issue #2819 : Fatal error when undo X-Git-Tag: End2018~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cd48bec142b65b9a3cb042ba09df6174f29db715;p=modules%2Fshaper.git Fix for the issue #2819 : Fatal error when undo --- diff --git a/src/Model/Model_AttributeRefList.cpp b/src/Model/Model_AttributeRefList.cpp index 7ffe0c4d3..23849b7c5 100644 --- a/src/Model/Model_AttributeRefList.cpp +++ b/src/Model/Model_AttributeRefList.cpp @@ -315,8 +315,9 @@ void Model_AttributeRefList::reinit() void Model_AttributeRefList::createHash() { - if (myHashUsed) + if (myHashUsed) { return; + } eraseHash(); std::shared_ptr aDoc = std::dynamic_pointer_cast( owner()->document()); @@ -331,8 +332,6 @@ void Model_AttributeRefList::createHash() myHashObjects.insert(anObj); } } - if (!myHashObjects.empty()) // on open document with multi-rotation referenced have no results - myHashUsed = true; } } diff --git a/src/Model/Model_AttributeRefList.h b/src/Model/Model_AttributeRefList.h index 9780013ef..f8502a8b5 100644 --- a/src/Model/Model_AttributeRefList.h +++ b/src/Model/Model_AttributeRefList.h @@ -86,7 +86,11 @@ public: /// Returns true if attribute was initialized by some value MODEL_EXPORT virtual bool isInitialized(); - protected: + + /// Erases the hashed objects caused by complicated modifications in the list + void eraseHash(); + +protected: /// Objects are created for features automatically MODEL_EXPORT Model_AttributeRefList(TDF_Label& theLabel); /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc) @@ -97,8 +101,6 @@ public: std::shared_ptr theDoc) const; /// Creates the hash-objects containers (does nothing if hash is already correct) void createHash(); - /// Erases the hashed objects caused by complicated modifications in the list - void eraseHash(); friend class Model_Data; }; diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 0d6479c3f..3fc0035b2 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -995,6 +996,12 @@ void Model_Objects::synchronizeBackRefsForObject(const std::set& t // iterate new list to compare with current std::set::iterator aNewIter = theNewRefs.begin(); for(; aNewIter != theNewRefs.end(); aNewIter++) { + // for the Model_AttributeRefList erase cash (issue #2819) + std::shared_ptr aRefList = + std::dynamic_pointer_cast(*aNewIter); + if (aRefList) + aRefList->eraseHash(); + if (aData->refsToMe().find(*aNewIter) == aData->refsToMe().end()) { FeaturePtr aRefFeat = std::dynamic_pointer_cast((*aNewIter)->owner()); if (aRefFeat)