summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-06-20 22:57:07 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-06-20 22:57:07 -0300
commitd76ee09774c546476b350c15a4197d2b9ae160dc (patch)
treed01b955274aac8bd3bfc8480bcdad60f5d16d143 /tools
parent9b8f2741aee4604bd7a84ac746fae58ae06a4267 (diff)
property remove parent owned nodes when using replace, fixes #4128
Diffstat (limited to 'tools')
-rw-r--r--tools/editor/scene_tree_dock.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp
index 69d6d97980..30ffdf6664 100644
--- a/tools/editor/scene_tree_dock.cpp
+++ b/tools/editor/scene_tree_dock.cpp
@@ -1388,6 +1388,13 @@ void SceneTreeDock::_create() {
}
String newname=n->get_name();
+
+ List<Node*> to_erase;
+ for(int i=0;i<n->get_child_count();i++) {
+ if (n->get_child(i)->get_owner()==NULL && n->is_owned_by_parent()) {
+ to_erase.push_back(n->get_child(i));
+ }
+ }
n->replace_by(newnode,true);
if (n==edited_scene) {
@@ -1408,6 +1415,11 @@ void SceneTreeDock::_create() {
memdelete(n);
+ while(to_erase.front()) {
+ memdelete(to_erase.front()->get());
+ to_erase.pop_front();
+ }
+
}