From aa693dd95f72eb9745b68aba528d5fc6f97be717 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 6 Dec 2016 10:16:27 +0100 Subject: [PATCH] Destroy the planes when the image_item is destroyed. --- .../Plugins/Mesh_3/Io_image_plugin.cpp | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp index d7128b9dfb0..80381c8d6ce 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp @@ -652,7 +652,7 @@ private: group_map[seg_img] = c; current_control = &group_map[seg_img]; connect(seg_img, SIGNAL(aboutToBeDestroyed()), - this, SLOT(erase_group())); + this, SLOT(on_img_detroyed())); threads.push_back(new X_plane_thread(x_item, img, clamper, name)); @@ -735,7 +735,37 @@ private Q_SLOTS: } } } - + //try to re-connect to another group + if(!group_map.isEmpty()) + { + int id = scene->item_id(group_map.keys().first()); + connect_controls(id); + } + } + //destroy planes on image deletion + void on_img_detroyed() + { + Scene_image_item* img_item = qobject_cast(sender()); + if(img_item) + { + Scene_group_item* group = qobject_cast(group_map[img_item].group); + if(!group) + return; + group_map[img_item].x_item = NULL; + group_map[img_item].y_item = NULL; + group_map[img_item].z_item = NULL; + disconnect(group_map[img_item].group, SIGNAL(aboutToBeDestroyed()), + this, SLOT(erase_group())); + group_map.remove(img_item); + QList deletion; + Q_FOREACH(Scene_item* child, group->getChildren()) + { + group->unlockChild(child); + deletion.append(scene->item_id(child)); + } + deletion.append(scene->item_id(group)); + static_cast(scene)->erase(deletion); + } //try to re-connect to another group if(!group_map.isEmpty()) { @@ -807,7 +837,7 @@ private Q_SLOTS: connect(z_slider, SIGNAL(realChange(int)), z_cubeLabel, SLOT(setNum(int))); connect(z_plane, SIGNAL(manipulated(int)), z_cubeLabel, SLOT(setNum(int))); connect(z_plane, SIGNAL(aboutToBeDestroyed()), this, SLOT(destroy_z_item())); - connect(x_slider, SIGNAL(sliderMoved(int)), z_slider, SLOT(updateFramePosition())); + connect(z_slider, SIGNAL(sliderMoved(int)), z_slider, SLOT(updateFramePosition())); connect(z_slider, SIGNAL(realChange(int)), this, SLOT(set_value())); z_slider->setValue(c.z_value); z_box->addWidget(z_slider);