Rewrite PropertyTopoShape::getShape to fix dangling reference

This commit is contained in:
bgbsww
2024-04-01 13:30:41 -04:00
committed by Chris Hennes
parent ecf6532969
commit 99da05f8a6
2 changed files with 5 additions and 6 deletions

View File

@@ -100,21 +100,20 @@ const TopoDS_Shape& PropertyPartShape::getValue() const
return _Shape.getShape();
}
TopoShape PropertyPartShape::getShape() const
const TopoShape& PropertyPartShape::getShape() const
{
_Shape.initCache(-1);
auto res = _Shape;
// March, 2024 Toponaming project: There was originally an unused feature to disable
// elementMapping that has not been kept:
// if (Feature::isElementMappingDisabled(getContainer()))
// res.Tag = -1;
// else if (!res.Tag) {
if (!res.Tag) {
if (!_Shape.Tag) {
if (auto parent = Base::freecad_dynamic_cast<App::DocumentObject>(getContainer())) {
res.Tag = parent->getID();
_Shape.Tag = parent->getID();
}
}
return res;
return _Shape;
}
const Data::ComplexGeoData* PropertyPartShape::getComplexData() const

View File

@@ -55,7 +55,7 @@ public:
void setValue(const TopoDS_Shape&, bool resetElementMap=true);
/// get the part shape
const TopoDS_Shape& getValue() const;
TopoShape getShape() const;
const TopoShape& getShape() const;
const Data::ComplexGeoData* getComplexData() const override;
//@}