Don't try updating wrong NodePaths in resources
This commit is contained in:
parent
51f81e1c88
commit
a5c984412c
@ -1635,10 +1635,15 @@ bool SceneTreeDock::_update_node_path(Node *p_root_node, NodePath &r_node_path,
|
|||||||
return false;
|
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()) {
|
switch (r_variant.get_type()) {
|
||||||
case Variant::NODE_PATH: {
|
case Variant::NODE_PATH: {
|
||||||
NodePath node_path = r_variant;
|
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)) {
|
if (!node_path.is_empty() && _update_node_path(p_root_node, node_path, p_renames)) {
|
||||||
r_variant = node_path;
|
r_variant = node_path;
|
||||||
return true;
|
return true;
|
||||||
@ -1650,7 +1655,7 @@ bool SceneTreeDock::_check_node_path_recursive(Node *p_root_node, Variant &r_var
|
|||||||
bool updated = false;
|
bool updated = false;
|
||||||
for (int i = 0; i < a.size(); i++) {
|
for (int i = 0; i < a.size(); i++) {
|
||||||
Variant value = a[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) {
|
if (!updated) {
|
||||||
a = a.duplicate(); // Need to duplicate for undo-redo to work.
|
a = a.duplicate(); // Need to duplicate for undo-redo to work.
|
||||||
updated = true;
|
updated = true;
|
||||||
@ -1669,7 +1674,7 @@ bool SceneTreeDock::_check_node_path_recursive(Node *p_root_node, Variant &r_var
|
|||||||
bool updated = false;
|
bool updated = false;
|
||||||
for (int i = 0; i < d.size(); i++) {
|
for (int i = 0; i < d.size(); i++) {
|
||||||
Variant value = d.get_value_at_index(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) {
|
if (!updated) {
|
||||||
d = d.duplicate(); // Need to duplicate for undo-redo to work.
|
d = d.duplicate(); // Need to duplicate for undo-redo to work.
|
||||||
updated = true;
|
updated = true;
|
||||||
@ -1699,7 +1704,7 @@ bool SceneTreeDock::_check_node_path_recursive(Node *p_root_node, Variant &r_var
|
|||||||
String propertyname = E.name;
|
String propertyname = E.name;
|
||||||
Variant old_variant = resource->get(propertyname);
|
Variant old_variant = resource->get(propertyname);
|
||||||
Variant updated_variant = old_variant;
|
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();
|
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||||
undo_redo->add_do_property(resource, propertyname, updated_variant);
|
undo_redo->add_do_property(resource, propertyname, updated_variant);
|
||||||
undo_redo->add_undo_property(resource, propertyname, old_variant);
|
undo_redo->add_undo_property(resource, propertyname, old_variant);
|
||||||
|
@ -281,7 +281,7 @@ class SceneTreeDock : public VBoxContainer {
|
|||||||
static void _update_configuration_warning();
|
static void _update_configuration_warning();
|
||||||
|
|
||||||
bool _update_node_path(Node *p_root_node, NodePath &r_node_path, HashMap<Node *, NodePath> *p_renames) const;
|
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);
|
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);
|
void _replace_node(Node *p_node, Node *p_by_node, bool p_keep_properties = true, bool p_remove_old = true);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user