Sketcher: Sketch - extraction of geometry as GeoList with owned memory allocation

=================================================================================

Apart from simplifying code, the allocated memory is not managed by the lifetime of the unique pointer owned by the GeometryFacade, preventing memory leaks.
This commit is contained in:
Abdullah Tahiri
2021-12-21 20:27:44 +01:00
committed by abdullahtahiriyo
parent bc6e4c1355
commit e91dcf39c1
2 changed files with 20 additions and 0 deletions

View File

@@ -1425,6 +1425,22 @@ std::vector<Part::Geometry *> Sketch::extractGeometry(bool withConstructionEleme
return temp;
}
GeoListFacade Sketch::extractGeoListFacade() const
{
std::vector<GeometryFacadeUniquePtr> temp;
temp.reserve(Geoms.size());
int internalGeometryCount = 0;
for (std::vector<GeoDef>::const_iterator it=Geoms.begin(); it != Geoms.end(); ++it) {
auto gf = GeometryFacade::getFacade(it->geo->clone(), true); // GeometryFacade is the owner of this allocation
if(!it->external)
internalGeometryCount++;
temp.push_back(std::move(gf));
}
return GeoListFacade::getGeoListModel(std::move(temp), internalGeometryCount);
}
void Sketch::updateExtension(int geoId, std::unique_ptr<Part::GeometryExtension> && ext)
{
geoId = checkGeoId(geoId);