summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorrobfram <robfram@gmail.com>2018-03-09 19:05:04 +0100
committerrobfram <robfram@gmail.com>2018-03-09 19:05:04 +0100
commit8ea4ea0d53e772673dea69a9df83aa8445ad49ea (patch)
treef3c81427624f075d3eff933b16e99521ae280ed6 /editor
parentb84236944215445be191047ab628e570ffd69e99 (diff)
Fix overwriting all common properties when using `Change Type` tool
If you change the type of an existing node, it checks if you have modified the initial value of their properties before overwriting their values in the new node. For example, if you created a `Label` and changed it to `LineEdit`, the `mouse_filter` property was created as `Ignore` for the original `Label` node, and was maintained after changing it to `LineEdit` causing not to work as expected. Now it checks if `Ignore` is the default value for `Label` nodes, and as it is, the property value is left unchanged, maintaining the default value for `LineEdit`, which is `Stop`. Fix #13955 and alike.
Diffstat (limited to 'editor')
-rw-r--r--editor/scene_tree_dock.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 9f0f62592b..002d702bac 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -1411,6 +1411,7 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node) {
Node *n = p_node;
Node *newnode = p_by_node;
+ Node *default_oldnode = Object::cast_to<Node>(ClassDB::instance(n->get_class()));
List<PropertyInfo> pinfo;
n->get_property_list(&pinfo);
@@ -1419,8 +1420,11 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node) {
continue;
if (E->get().name == "__meta__")
continue;
- newnode->set(E->get().name, n->get(E->get().name));
+ if (default_oldnode->get(E->get().name) != n->get(E->get().name)) {
+ newnode->set(E->get().name, n->get(E->get().name));
+ }
}
+ memdelete(default_oldnode);
editor->push_item(NULL);