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:
committed by
abdullahtahiriyo
parent
62bb8f67c8
commit
dfd726ec35
@@ -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);
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <App/PropertyFile.h>
|
||||
#include <Mod/Part/App/Geometry.h>
|
||||
#include <Mod/Part/App/TopoShape.h>
|
||||
#include "GeoList.h"
|
||||
#include "Constraint.h"
|
||||
|
||||
#include "planegcs/GCS.h"
|
||||
@@ -36,6 +37,7 @@
|
||||
namespace Sketcher
|
||||
{
|
||||
|
||||
|
||||
class SketcherExport Sketch :public Base::Persistence
|
||||
{
|
||||
TYPESYSTEM_HEADER();
|
||||
@@ -89,6 +91,8 @@ public:
|
||||
std::vector<Part::Geometry *> extractGeometry(bool withConstructionElements=true,
|
||||
bool withExternalElements=false) const;
|
||||
|
||||
GeoListFacade extractGeoListFacade() const;
|
||||
|
||||
void updateExtension(int geoId, std::unique_ptr<Part::GeometryExtension> && ext);
|
||||
/// get the geometry as python objects
|
||||
Py::Tuple getPyGeometry(void) const;
|
||||
|
||||
Reference in New Issue
Block a user