diff options
Diffstat (limited to 'editor/scene_tree_dock.cpp')
| -rw-r--r-- | editor/scene_tree_dock.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index a38487635f..9d69addc12 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -1635,10 +1635,15 @@ bool SceneTreeDock::_update_node_path(Node *p_root_node, NodePath &r_node_path, return false; } -bool SceneTreeDock::_check_node_path_recursive(Node *p_root_node, Variant &r_variant, HashMap<Node *, NodePath> *p_renames) const { +bool SceneTreeDock::_check_node_path_recursive(Node *p_root_node, Variant &r_variant, HashMap<Node *, NodePath> *p_renames, bool p_inside_resource) const { switch (r_variant.get_type()) { case Variant::NODE_PATH: { NodePath node_path = r_variant; + if (p_inside_resource && !p_root_node->has_node(node_path)) { + // Resources may have NodePaths to nodes that aren't on the scene, so skip them. + return false; + } + if (!node_path.is_empty() && _update_node_path(p_root_node, node_path, p_renames)) { r_variant = node_path; return true; @@ -1650,7 +1655,7 @@ bool SceneTreeDock::_check_node_path_recursive(Node *p_root_node, Variant &r_var bool updated = false; for (int i = 0; i < a.size(); i++) { Variant value = a[i]; - if (_check_node_path_recursive(p_root_node, value, p_renames)) { + if (_check_node_path_recursive(p_root_node, value, p_renames, p_inside_resource)) { if (!updated) { a = a.duplicate(); // Need to duplicate for undo-redo to work. updated = true; @@ -1669,7 +1674,7 @@ bool SceneTreeDock::_check_node_path_recursive(Node *p_root_node, Variant &r_var bool updated = false; for (int i = 0; i < d.size(); i++) { Variant value = d.get_value_at_index(i); - if (_check_node_path_recursive(p_root_node, value, p_renames)) { + if (_check_node_path_recursive(p_root_node, value, p_renames, p_inside_resource)) { if (!updated) { d = d.duplicate(); // Need to duplicate for undo-redo to work. updated = true; @@ -1699,7 +1704,7 @@ bool SceneTreeDock::_check_node_path_recursive(Node *p_root_node, Variant &r_var String propertyname = E.name; Variant old_variant = resource->get(propertyname); Variant updated_variant = old_variant; - if (_check_node_path_recursive(p_root_node, updated_variant, p_renames)) { + if (_check_node_path_recursive(p_root_node, updated_variant, p_renames, true)) { EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); undo_redo->add_do_property(resource, propertyname, updated_variant); undo_redo->add_undo_property(resource, propertyname, old_variant); |
