diff --git a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp index 937796bf0cf..08a63e2bf8d 100644 --- a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp @@ -280,9 +280,6 @@ struct Scene_c3t3_item_priv { invalidate_stats(); } ~Scene_c3t3_item_priv() - { - } - void destroy() { c3t3.clear(); tree.clear(); @@ -294,6 +291,7 @@ struct Scene_c3t3_item_priv { delete tet_Slider; } } + void init_default_values() { positions_lines.resize(0); positions_poly.resize(0); @@ -531,7 +529,6 @@ Scene_c3t3_item::~Scene_c3t3_item() { if(d) { - d->destroy(); delete d; d = NULL; } @@ -2018,9 +2015,17 @@ void Scene_c3t3_item::itemAboutToBeDestroyed(Scene_item *item) { Scene_item::itemAboutToBeDestroyed(item); - if(d) + if(d && item == this) { - d->destroy(); + d->c3t3.clear(); + d->tree.clear(); + if(d->frame) + { + static_cast(QGLViewer::QGLViewerPool().first())->setManipulatedFrame(0); + delete d->frame; + d->frame = NULL; + delete d->tet_Slider; + } delete d; d=0; } diff --git a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.h b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.h index 390da10691f..a5fbb23568a 100644 --- a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.h @@ -149,7 +149,7 @@ public: QColor get_histogram_color(const double v) const; - void itemAboutToBeDestroyed(Scene_item *); + void itemAboutToBeDestroyed(Scene_item *) Q_DECL_OVERRIDE; protected: friend struct Scene_c3t3_item_priv; diff --git a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp index f0cdce0798c..e924d47bdfe 100644 --- a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp @@ -877,7 +877,7 @@ int Scene_points_with_normal_item::getPointSliderValue() void Scene_points_with_normal_item::itemAboutToBeDestroyed(Scene_item *item) { Scene_item::itemAboutToBeDestroyed(item); - if(d && d->m_points) + if(d && d->m_points && item == this) { delete d->m_points; d->m_points = NULL; diff --git a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h index 4c32f4f5749..41c938492ef 100644 --- a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h @@ -89,7 +89,7 @@ public Q_SLOTS: void pointSliderPressed(); //Set the status of the slider as `released` void pointSliderReleased(); - void itemAboutToBeDestroyed(Scene_item *); + void itemAboutToBeDestroyed(Scene_item *) Q_DECL_OVERRIDE; // Data protected: diff --git a/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.cpp b/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.cpp index edcc6a0854c..cc912635d9a 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.cpp @@ -854,13 +854,12 @@ std::vector Scene_polygon_soup_item::getFColors() const{return d->s void Scene_polygon_soup_item::itemAboutToBeDestroyed(Scene_item *item) { Scene_item::itemAboutToBeDestroyed(item); - if(d) - { - if(d->soup) - { - delete d->soup; - d->soup=NULL; - } - } - + if(d && item == this) + { + if(d->soup) + { + delete d->soup; + d->soup=NULL; + } + } } diff --git a/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.h b/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.h index 9ac9779b2f2..767deb6f3ab 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.h @@ -151,7 +151,7 @@ public Q_SLOTS: void setDisplayNonManifoldEdges(const bool); bool displayNonManifoldEdges() const; - void itemAboutToBeDestroyed(Scene_item *item); + void itemAboutToBeDestroyed(Scene_item *item) Q_DECL_OVERRIDE; protected: friend struct Scene_polygon_soup_item_priv; diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.cpp b/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.cpp index c8679dbcb3d..b439e4bf04f 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.cpp @@ -94,6 +94,11 @@ struct Scene_polyhedron_item_priv{ { init_default_values(); } + ~Scene_polyhedron_item_priv() + { + delete poly; + delete targeted_id; + } void init_default_values() { show_only_feature_edges_m = false; @@ -123,11 +128,6 @@ struct Scene_polyhedron_item_priv{ const bool colors_only) const; void init(); void invalidate_stats(); - void destroy() - { - delete poly; - delete targeted_id; - } void* get_aabb_tree(); QList triangulate_primitive(Polyhedron::Facet_iterator fit, Traits::Vector_3 normal); @@ -823,7 +823,6 @@ Scene_polyhedron_item::~Scene_polyhedron_item() } if(d) { - d->destroy(); delete d; d=NULL; } @@ -1848,9 +1847,8 @@ void Scene_polyhedron_item::set_flat_disabled(bool b) void Scene_polyhedron_item::itemAboutToBeDestroyed(Scene_item *item) { Scene_item::itemAboutToBeDestroyed(item); - if(d) + if(d && item == this) { - d->destroy(); delete d; d=NULL; } diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.h b/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.h index f344911dc11..bd3c59a2ab7 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.h @@ -142,7 +142,7 @@ public Q_SLOTS: void update_facet_indices(); void update_halfedge_indices(); void invalidate_aabb_tree(); - void itemAboutToBeDestroyed(Scene_item *); + void itemAboutToBeDestroyed(Scene_item *) Q_DECL_OVERRIDE; Q_SIGNALS: void selection_done(); diff --git a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp index 45db04a104d..ddc70183286 100644 --- a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp @@ -646,7 +646,7 @@ void Scene_surface_mesh_item::compute_bbox()const void Scene_surface_mesh_item::itemAboutToBeDestroyed(Scene_item *item) { Scene_item::itemAboutToBeDestroyed(item); - if(d && d->smesh_) + if(d && d->smesh_ && item == this) { delete d->smesh_; d->smesh_ = NULL; diff --git a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.h b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.h index 42f01f25dbd..e0037cdf4eb 100644 --- a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.h @@ -53,7 +53,7 @@ public: const SMesh* polyhedron() const; void compute_bbox()const; public Q_SLOTS: - void itemAboutToBeDestroyed(Scene_item *); + void itemAboutToBeDestroyed(Scene_item *) Q_DECL_OVERRIDE; virtual void selection_changed(bool); protected: friend struct Scene_surface_mesh_item_priv;