diff options
| author | robfram | 2018-03-09 19:05:04 +0100 |
|---|---|---|
| committer | Hein-Pieter van Braam | 2018-04-28 15:47:57 +0200 |
| commit | d49579b038df558ddd70605f07e2000d4a42c2f8 (patch) | |
| tree | 5f4f2f78486ee6657cf8c400ba6210ec057d6d00 /editor/scene_tree_dock.cpp | |
| parent | a3ba1b0280228468c1847f21ef229350979af0d7 (diff) | |
| download | godot-d49579b038df558ddd70605f07e2000d4a42c2f8.tar.gz godot-d49579b038df558ddd70605f07e2000d4a42c2f8.tar.zst godot-d49579b038df558ddd70605f07e2000d4a42c2f8.zip | |
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.
(cherry picked from commit 8ea4ea0d53e772673dea69a9df83aa8445ad49ea)
Diffstat (limited to 'editor/scene_tree_dock.cpp')
| -rw-r--r-- | editor/scene_tree_dock.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 45622d43e..9a4bd9a56 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -1402,6 +1402,8 @@ void SceneTreeDock::_create() { Node *newnode = Object::cast_to<Node>(c); ERR_FAIL_COND(!newnode); + Node *default_oldnode = Object::cast_to<Node>(ClassDB::instance(n->get_class())); + List<PropertyInfo> pinfo; n->get_property_list(&pinfo); @@ -1410,10 +1412,13 @@ void SceneTreeDock::_create() { 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)); + } } editor->push_item(NULL); + memdelete(default_oldnode); //reconnect signals List<MethodInfo> sl; |
