summaryrefslogtreecommitdiff
path: root/scene/property_utils.cpp
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2021-12-11 14:03:48 +0100
committerPedro J. Estébanez <pedrojrulez@gmail.com>2021-12-11 14:03:48 +0100
commit18663aa305ef1ed5c87efd74425146112322b91f (patch)
treebfbe62692d1b878aaf1364c69743ddb0b18e4aa6 /scene/property_utils.cpp
parent092a2861277e7df87aec10516d713d0bf4adba79 (diff)
Stop asuming a default value of NIL means there's no default
Diffstat (limited to 'scene/property_utils.cpp')
-rw-r--r--scene/property_utils.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/scene/property_utils.cpp b/scene/property_utils.cpp
index e3c65bbc6e..6ffc1f148a 100644
--- a/scene/property_utils.cpp
+++ b/scene/property_utils.cpp
@@ -50,7 +50,7 @@ bool PropertyUtils::is_property_value_different(const Variant &p_a, const Varian
}
}
-Variant PropertyUtils::get_property_default_value(const Object *p_object, const StringName &p_property, const Vector<SceneState::PackState> *p_states_stack_cache, bool p_update_exports, const Node *p_owner, bool *r_is_class_default) {
+Variant PropertyUtils::get_property_default_value(const Object *p_object, const StringName &p_property, bool *r_is_valid, const Vector<SceneState::PackState> *p_states_stack_cache, bool p_update_exports, const Node *p_owner, bool *r_is_class_default) {
// This function obeys the way property values are set when an object is instantiated,
// which is the following (the latter wins):
// 1. Default value from builtin class
@@ -60,6 +60,9 @@ Variant PropertyUtils::get_property_default_value(const Object *p_object, const
if (r_is_class_default) {
*r_is_class_default = false;
}
+ if (r_is_valid) {
+ *r_is_valid = false;
+ }
Ref<Script> topmost_script;
@@ -71,6 +74,9 @@ Variant PropertyUtils::get_property_default_value(const Object *p_object, const
bool found = false;
Variant value_in_ancestor = ia.state->get_property_value(ia.node, p_property, found);
if (found) {
+ if (r_is_valid) {
+ *r_is_valid = true;
+ }
return value_in_ancestor;
}
// Save script for later
@@ -97,6 +103,9 @@ Variant PropertyUtils::get_property_default_value(const Object *p_object, const
}
Variant default_value;
if (topmost_script->get_property_default_value(p_property, default_value)) {
+ if (r_is_valid) {
+ *r_is_valid = true;
+ }
return default_value;
}
}
@@ -105,7 +114,7 @@ Variant PropertyUtils::get_property_default_value(const Object *p_object, const
if (r_is_class_default) {
*r_is_class_default = true;
}
- return ClassDB::class_get_default_property_value(p_object->get_class_name(), p_property);
+ return ClassDB::class_get_default_property_value(p_object->get_class_name(), p_property, r_is_valid);
}
// Like SceneState::PackState, but using a raw pointer to avoid the cost of