From d1cda5bd31237a3739649380f096533b1d245ef5 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 8 Jun 2023 12:54:59 +0200 Subject: [PATCH] fix various memory leaks in CGAL Lab --- Polyhedron/demo/Polyhedron/Point_container.cpp | 6 +++++- Three/include/CGAL/Three/Point_container.h | 2 ++ Three/include/CGAL/Three/Primitive_container.h | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Point_container.cpp b/Polyhedron/demo/Polyhedron/Point_container.cpp index a7e4c37a88e4..014d016fdea0 100644 --- a/Polyhedron/demo/Polyhedron/Point_container.cpp +++ b/Polyhedron/demo/Polyhedron/Point_container.cpp @@ -27,6 +27,11 @@ Point_container::Point_container(int program, bool indexed) } +Point_container::~Point_container() +{ + delete d; +} + void Point_container::initGL(Viewer_interface *viewer) { viewer->makeCurrent(); @@ -64,7 +69,6 @@ void Point_container::initGL(Viewer_interface *viewer) setVbo(Colors, new Vbo("colors", Vbo::COLORS)); - setVao(viewer, new Vao(viewer->getShaderProgram(getProgram()))); if(viewer->getShaderProgram(getProgram())->property("hasNormals").toBool()) { if(!getVbo(Normals)) diff --git a/Three/include/CGAL/Three/Point_container.h b/Three/include/CGAL/Three/Point_container.h index 5527a76d8fc0..4168c8fb5e4c 100644 --- a/Three/include/CGAL/Three/Point_container.h +++ b/Three/include/CGAL/Three/Point_container.h @@ -55,6 +55,8 @@ struct DEMO_FRAMEWORK_EXPORT Point_container :public Primitive_container //! Point_container(int program, bool indexed); + ~Point_container(); + //! //! \brief initGL creates the `Vbo`s and `Vao`s of this `Point_container`. //! \attention It must be called within a valid OpenGL context. The `draw()` function of an item is always a safe place to call this. diff --git a/Three/include/CGAL/Three/Primitive_container.h b/Three/include/CGAL/Three/Primitive_container.h index 34dea54aa660..613af38b7e9c 100644 --- a/Three/include/CGAL/Three/Primitive_container.h +++ b/Three/include/CGAL/Three/Primitive_container.h @@ -19,6 +19,8 @@ #include #include +#include // for std::unique_ptr + using namespace CGAL::Three; #ifdef demo_framework_EXPORTS @@ -248,7 +250,7 @@ class DEMO_FRAMEWORK_EXPORT Primitive_container //! private: friend struct D; - mutable D* d; + std::unique_ptr d; }; //end of class Triangle_container }