Merge pull request #83263 from KoBeWi/invalid_node﹖oh_no…_anyway
Don't try updating wrong NodePaths in resources
This commit is contained in:
commit
81f4953c3a
2 changed files with 10 additions and 5 deletions
|
@ -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);
|
||||
|
|
|
@ -281,7 +281,7 @@ class SceneTreeDock : public VBoxContainer {
|
|||
static void _update_configuration_warning();
|
||||
|
||||
bool _update_node_path(Node *p_root_node, NodePath &r_node_path, HashMap<Node *, NodePath> *p_renames) const;
|
||||
bool _check_node_path_recursive(Node *p_root_node, Variant &r_variant, HashMap<Node *, NodePath> *p_renames) const;
|
||||
bool _check_node_path_recursive(Node *p_root_node, Variant &r_variant, HashMap<Node *, NodePath> *p_renames, bool p_inside_resource = false) const;
|
||||
bool _check_node_recursive(Variant &r_variant, Node *p_node, Node *p_by_node, const String type_hint, String &r_warn_message);
|
||||
void _replace_node(Node *p_node, Node *p_by_node, bool p_keep_properties = true, bool p_remove_old = true);
|
||||
|
||||
|
|
Loading…
Reference in a new issue