1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-05-01 10:26:12 +03:00

refs #369: Crash deleting thread of notes

* XCAFDoc_NotesTool, incorrect removing parent/child from XCAFDoc_GraphNode attribute in loops
This commit is contained in:
snn 2017-05-25 14:28:43 +03:00
parent 7ab2d56e84
commit af131bd03e

View File

@ -522,10 +522,9 @@ XCAFDoc_NotesTool::RemoveAllNotes(const XCAFDoc_AssemblyItemId& theItemId,
if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild)) if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild))
return Standard_False; return Standard_False;
Standard_Integer nbFathers = aChild->NbFathers(); while (aChild->NbFathers() > 0)
for (Standard_Integer iFather = 1; iFather <= nbFathers; ++iFather)
{ {
Handle(XCAFDoc_GraphNode) aFather = aChild->GetFather(iFather); Handle(XCAFDoc_GraphNode) aFather = aChild->GetFather(1);
Handle(XCAFDoc_Note) aNote = XCAFDoc_Note::Get(aFather->Label()); Handle(XCAFDoc_Note) aNote = XCAFDoc_Note::Get(aFather->Label());
if (!aNote.IsNull()) if (!aNote.IsNull())
{ {
@ -553,10 +552,9 @@ XCAFDoc_NotesTool::RemoveAllSubshapeNotes(const XCAFDoc_AssemblyItemId& theItemI
if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild)) if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild))
return Standard_False; return Standard_False;
Standard_Integer nbFathers = aChild->NbFathers(); while (aChild->NbFathers() > 0)
for (Standard_Integer iFather = 1; iFather <= nbFathers; ++iFather)
{ {
Handle(XCAFDoc_GraphNode) aFather = aChild->GetFather(iFather); Handle(XCAFDoc_GraphNode) aFather = aChild->GetFather(1);
Handle(XCAFDoc_Note) aNote = XCAFDoc_Note::Get(aFather->Label()); Handle(XCAFDoc_Note) aNote = XCAFDoc_Note::Get(aFather->Label());
if (!aNote.IsNull()) if (!aNote.IsNull())
{ {
@ -584,10 +582,9 @@ XCAFDoc_NotesTool::RemoveAllAttrNotes(const XCAFDoc_AssemblyItemId& theItemId,
if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild)) if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild))
return Standard_False; return Standard_False;
Standard_Integer nbFathers = aChild->NbFathers(); while (aChild->NbFathers())
for (Standard_Integer iFather = 1; iFather <= nbFathers; ++iFather)
{ {
Handle(XCAFDoc_GraphNode) aFather = aChild->GetFather(iFather); Handle(XCAFDoc_GraphNode) aFather = aChild->GetFather(1);
Handle(XCAFDoc_Note) aNote = XCAFDoc_Note::Get(aFather->Label()); Handle(XCAFDoc_Note) aNote = XCAFDoc_Note::Get(aFather->Label());
if (!aNote.IsNull()) if (!aNote.IsNull())
{ {
@ -611,11 +608,10 @@ XCAFDoc_NotesTool::DeleteNote(const TDF_Label& theNoteLabel)
Handle(XCAFDoc_GraphNode) aFather; Handle(XCAFDoc_GraphNode) aFather;
if (theNoteLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aFather) && !aFather.IsNull()) if (theNoteLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aFather) && !aFather.IsNull())
{ {
Standard_Integer nbChildren = aFather->NbChildren(); while (aFather->NbChildren() > 0)
for (Standard_Integer iChild = 1; iChild <= nbChildren; ++iChild)
{ {
Handle(XCAFDoc_GraphNode) aChild = aFather->GetChild(iChild); Handle(XCAFDoc_GraphNode) aChild = aFather->GetChild(1);
aFather->UnSetChild(iChild); aFather->UnSetChild(aChild);
if (aChild->NbFathers() == 0) if (aChild->NbFathers() == 0)
aChild->Label().ForgetAttribute(aChild); aChild->Label().ForgetAttribute(aChild);
} }