From 7de691f1bce383a26cf4119d8ed87f421a09981b Mon Sep 17 00:00:00 2001 From: mpv Date: Fri, 16 May 2014 12:22:30 +0400 Subject: [PATCH] Fixed crash on undo/redo --- src/Model/Model_AttributeRefAttr.cpp | 2 ++ src/Model/Model_Document.cpp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Model/Model_AttributeRefAttr.cpp b/src/Model/Model_AttributeRefAttr.cpp index daa53a1a6..16a86b194 100644 --- a/src/Model/Model_AttributeRefAttr.cpp +++ b/src/Model/Model_AttributeRefAttr.cpp @@ -80,5 +80,7 @@ Model_AttributeRefAttr::Model_AttributeRefAttr(TDF_Label& theLabel) // create attribute: not initialized by value yet myID = TDataStd_Comment::Set(theLabel, ""); myRef = TDF_Reference::Set(theLabel, theLabel); // not initialized: reference to itself + } else { + theLabel.FindAttribute(TDF_Reference::GetID(), myRef); } } diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 7618babe2..943992055 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -324,7 +324,8 @@ boost::shared_ptr Model_Document::feature(TDF_Label& theLabel) Handle(TDataStd_Comment) aGroupID; if (theLabel.Father().FindAttribute(TDataStd_Comment::GetID(), aGroupID)) { string aGroup = TCollection_AsciiString(aGroupID->Get()).ToCString(); - return myFeatures[aGroup][aFeatureIndex->Get()]; + if (myFeatures[aGroup].size() > aFeatureIndex->Get()) + return myFeatures[aGroup][aFeatureIndex->Get()]; } } return boost::shared_ptr(); // not found -- 2.39.2