summaryrefslogtreecommitdiffstats
path: root/scene/resources/packed_scene.cpp
diff options
context:
space:
mode:
author风青山 <idleman@yeah.net>2024-02-17 11:53:30 +0800
committer风青山 <idleman@yeah.net>2024-03-10 07:37:47 +0800
commit4d57da4d0154722306fa279e0c0e0438f3817b16 (patch)
treefa6066446f4f1d0475329f5024d743f0310b3b39 /scene/resources/packed_scene.cpp
parentb7145638d5b235e8e1b2fe039a0cee48a4bbb26d (diff)
downloadredot-engine-4d57da4d0154722306fa279e0c0e0438f3817b16.tar.gz
Fix inherited scenes produce errors in editor when "editable_children" is true
Since the same argument is used, `SceneState::get_node_deferred_nodepath_properties()` should use similar logic to `SceneState::get_property_value()`. Make `SceneState::get_property_value()` to return whether the property is deferred.
Diffstat (limited to 'scene/resources/packed_scene.cpp')
-rw-r--r--scene/resources/packed_scene.cpp40
1 files changed, 27 insertions, 13 deletions
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index a59ac9b56d..a2b04f5c80 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -1254,29 +1254,31 @@ int SceneState::_find_base_scene_node_remap_key(int p_idx) const {
return -1;
}
-Variant SceneState::get_property_value(int p_node, const StringName &p_property, bool &found) const {
- found = false;
+Variant SceneState::get_property_value(int p_node, const StringName &p_property, bool &r_found, bool &r_node_deferred) const {
+ r_found = false;
+ r_node_deferred = false;
ERR_FAIL_COND_V(p_node < 0, Variant());
if (p_node < nodes.size()) {
- //find in built-in nodes
+ // Find in built-in nodes.
int pc = nodes[p_node].properties.size();
const StringName *namep = names.ptr();
const NodeData::Property *p = nodes[p_node].properties.ptr();
for (int i = 0; i < pc; i++) {
if (p_property == namep[p[i].name & FLAG_PROP_NAME_MASK]) {
- found = true;
+ r_found = true;
+ r_node_deferred = p[i].name & FLAG_PATH_PROPERTY_IS_NODE;
return variants[p[i].value];
}
}
}
- //property not found, try on instance
-
- if (base_scene_node_remap.has(p_node)) {
- return get_base_scene_state()->get_property_value(base_scene_node_remap[p_node], p_property, found);
+ // Property not found, try on instance.
+ HashMap<int, int>::ConstIterator I = base_scene_node_remap.find(p_node);
+ if (I) {
+ return get_base_scene_state()->get_property_value(I->value, p_property, r_found, r_node_deferred);
}
return Variant();
@@ -1666,13 +1668,25 @@ StringName SceneState::get_node_property_name(int p_idx, int p_prop) const {
Vector<String> SceneState::get_node_deferred_nodepath_properties(int p_idx) const {
Vector<String> ret;
- ERR_FAIL_INDEX_V(p_idx, nodes.size(), ret);
- for (int i = 0; i < nodes[p_idx].properties.size(); i++) {
- uint32_t idx = nodes[p_idx].properties[i].name;
- if (idx & FLAG_PATH_PROPERTY_IS_NODE) {
- ret.push_back(names[idx & FLAG_PROP_NAME_MASK]);
+ ERR_FAIL_COND_V(p_idx < 0, ret);
+
+ if (p_idx < nodes.size()) {
+ // Find in built-in nodes.
+ for (int i = 0; i < nodes[p_idx].properties.size(); i++) {
+ uint32_t idx = nodes[p_idx].properties[i].name;
+ if (idx & FLAG_PATH_PROPERTY_IS_NODE) {
+ ret.push_back(names[idx & FLAG_PROP_NAME_MASK]);
+ }
}
+ return ret;
}
+
+ // Property not found, try on instance.
+ HashMap<int, int>::ConstIterator I = base_scene_node_remap.find(p_idx);
+ if (I) {
+ return get_base_scene_state()->get_node_deferred_nodepath_properties(I->value);
+ }
+
return ret;
}