property remove parent owned nodes when using replace, fixes #4128
This commit is contained in:
parent
9b8f2741ae
commit
d76ee09774
|
@ -2081,6 +2081,10 @@ void Node::update_configuration_warning() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Node::is_owned_by_parent() const {
|
||||||
|
data.parent_owned;
|
||||||
|
}
|
||||||
|
|
||||||
void Node::_bind_methods() {
|
void Node::_bind_methods() {
|
||||||
|
|
||||||
ObjectTypeDB::bind_method(_MD("_add_child_below_node","node:Node","child_node:Node","legible_unique_name"),&Node::add_child_below_node,DEFVAL(false));
|
ObjectTypeDB::bind_method(_MD("_add_child_below_node","node:Node","child_node:Node","legible_unique_name"),&Node::add_child_below_node,DEFVAL(false));
|
||||||
|
|
|
@ -313,6 +313,8 @@ public:
|
||||||
NodePath get_import_path() const;
|
NodePath get_import_path() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool is_owned_by_parent() const;
|
||||||
|
|
||||||
void get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const;
|
void get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const;
|
||||||
|
|
||||||
void clear_internal_tree_resource_paths();
|
void clear_internal_tree_resource_paths();
|
||||||
|
|
|
@ -1388,6 +1388,13 @@ void SceneTreeDock::_create() {
|
||||||
}
|
}
|
||||||
|
|
||||||
String newname=n->get_name();
|
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);
|
n->replace_by(newnode,true);
|
||||||
|
|
||||||
if (n==edited_scene) {
|
if (n==edited_scene) {
|
||||||
|
@ -1408,6 +1415,11 @@ void SceneTreeDock::_create() {
|
||||||
|
|
||||||
memdelete(n);
|
memdelete(n);
|
||||||
|
|
||||||
|
while(to_erase.front()) {
|
||||||
|
memdelete(to_erase.front()->get());
|
||||||
|
to_erase.pop_front();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue