Skip to content

Commit ad54cd4

Browse files
committed
Merge pull request #113353 from SatLess/oversight
Prevent double counting and cyclical error when gathering Resources
2 parents 39c7479 + 8b79e94 commit ad54cd4

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

editor/editor_node.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,7 +1815,9 @@ void EditorNode::gather_resources(const Variant &p_variant, List<Ref<Resource>>
18151815
r_list.push_back(res);
18161816
}
18171817
}
1818-
gather_resources(v, r_list, p_subresources, p_allow_external);
1818+
if (Object::cast_to<Node>(v) == nullptr) {
1819+
gather_resources(v, r_list, p_subresources, p_allow_external);
1820+
}
18191821
}
18201822
return;
18211823
}
@@ -1839,8 +1841,12 @@ void EditorNode::gather_resources(const Variant &p_variant, List<Ref<Resource>>
18391841
r_list.push_back(res_value);
18401842
}
18411843
}
1842-
gather_resources(kv.key, r_list, p_subresources, p_allow_external);
1843-
gather_resources(kv.value, r_list, p_subresources, p_allow_external);
1844+
if (Object::cast_to<Node>(kv.key) == nullptr) {
1845+
gather_resources(kv.key, r_list, p_subresources, p_allow_external);
1846+
}
1847+
if (Object::cast_to<Node>(kv.value) == nullptr) {
1848+
gather_resources(kv.value, r_list, p_subresources, p_allow_external);
1849+
}
18441850
}
18451851
return;
18461852
}
@@ -1855,12 +1861,10 @@ void EditorNode::gather_resources(const Variant &p_variant, List<Ref<Resource>>
18551861

18561862
Variant property_value = p_variant.get(E.name);
18571863
Variant::Type property_type = property_value.get_type();
1858-
18591864
if (property_type == Variant::ARRAY || property_type == Variant::DICTIONARY) {
18601865
gather_resources(property_value, r_list, p_subresources, p_allow_external);
18611866
continue;
18621867
}
1863-
18641868
Ref<Resource> res = property_value;
18651869
if (res.is_null()) {
18661870
continue;

editor/inspector/editor_inspector.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5182,9 +5182,9 @@ void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bo
51825182
} else {
51835183
undo_redo->add_undo_property(object, p_name, value);
51845184
}
5185-
// We'll use Editor Selection to get the currently edited Node.
51865185
Node *N = Object::cast_to<Node>(object);
5187-
if (N && (type == Variant::OBJECT || type == Variant::ARRAY || type == Variant::DICTIONARY) && value != p_value) {
5186+
bool double_counting = Object::cast_to<Node>(p_value) == N || Object::cast_to<Node>(value) == N;
5187+
if (N && !double_counting && (type == Variant::OBJECT || type == Variant::ARRAY || type == Variant::DICTIONARY) && value != p_value) {
51885188
undo_redo->add_do_method(EditorNode::get_singleton(), "update_node_reference", value, N, true);
51895189
undo_redo->add_do_method(EditorNode::get_singleton(), "update_node_reference", p_value, N, false);
51905190
// Perhaps an inefficient way of updating the resource count.

0 commit comments

Comments
 (0)