1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0030926: Data Exchange - Change of the number of GDT points of a View may lead to a crash

This commit is contained in:
vro 2019-08-29 16:20:50 +03:00 committed by apn
parent b383a61fbd
commit 990d032c90

View File

@ -250,13 +250,27 @@ Handle(XCAFView_Object) XCAFDoc_View::GetObject() const
// GDT Points // GDT Points
if (!Label().FindChild(ChildLab_GDTPoints, Standard_False).IsNull()) { if (!Label().FindChild(ChildLab_GDTPoints, Standard_False).IsNull()) {
TDF_Label aPointsLabel = Label().FindChild(ChildLab_GDTPoints); TDF_Label aPointsLabel = Label().FindChild(ChildLab_GDTPoints);
anObj->CreateGDTPoints(aPointsLabel.NbChildren());
for (Standard_Integer i = 1; i <= aPointsLabel.NbChildren(); i++) { // Find out the number of stored GDT-points in Ocaf tree.
gp_Pnt aPoint; Standard_Integer aNbGDTPoints = 0;
Handle(TDataXtd_Point) aGDTPointAttr; Handle(TDataXtd_Point) aGDTPointAttr;
aPointsLabel.FindChild(i).FindAttribute(TDataXtd_Point::GetID(), aGDTPointAttr); TDF_ChildIterator anItrPnts (aPointsLabel, Standard_False);
TDataXtd_Geometry::Point(aGDTPointAttr->Label(), aPoint); for (; anItrPnts.More(); anItrPnts.Next()) {
anObj->SetGDTPoint(i, aPoint); if (anItrPnts.Value().FindAttribute (TDataXtd_Point::GetID(), aGDTPointAttr))
aNbGDTPoints++;
}
// Allocate the GDT-points and fill them in from Ocaf tree.
if (aNbGDTPoints) {
anObj->CreateGDTPoints (aNbGDTPoints);
const Standard_Integer aNbChildren = aPointsLabel.NbChildren();
for (Standard_Integer aLabelIndex = 1, aPointIndex = 1; aLabelIndex <= aNbChildren; aLabelIndex++) {
gp_Pnt aPoint;
if (aPointsLabel.FindChild (aLabelIndex).FindAttribute (TDataXtd_Point::GetID(), aGDTPointAttr)) {
TDataXtd_Geometry::Point (aGDTPointAttr->Label(), aPoint);
anObj->SetGDTPoint (aPointIndex++, aPoint);
}
}
} }
} }