summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/gdscript/gdscript.cpp24
-rw-r--r--modules/gdscript/gdscript.h3
-rw-r--r--modules/text_server_adv/text_server_adv.cpp10
-rw-r--r--modules/text_server_adv/text_server_adv.h1
4 files changed, 38 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index 73abf71bde..19b264d764 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -678,6 +678,27 @@ Error GDScript::_static_init() {
#ifdef TOOLS_ENABLED
+void GDScript::_static_default_init() {
+ for (const KeyValue<StringName, MemberInfo> &E : static_variables_indices) {
+ const GDScriptDataType &type = E.value.data_type;
+ // Only initialize builtin types, which are not expected to be `null`.
+ if (!type.has_type || type.kind != GDScriptDataType::BUILTIN) {
+ continue;
+ }
+ if (type.builtin_type == Variant::ARRAY && type.has_container_element_type(0)) {
+ Array default_value;
+ const GDScriptDataType &element_type = type.get_container_element_type(0);
+ default_value.set_typed(element_type.builtin_type, element_type.native_type, element_type.script_type);
+ static_variables.write[E.value.index] = default_value;
+ } else {
+ Variant default_value;
+ Callable::CallError err;
+ Variant::construct(type.builtin_type, default_value, nullptr, 0, err);
+ static_variables.write[E.value.index] = default_value;
+ }
+ }
+}
+
void GDScript::_save_old_static_data() {
old_static_variables_indices = static_variables_indices;
old_static_variables = static_variables;
@@ -841,6 +862,9 @@ Error GDScript::reload(bool p_keep_state) {
#ifdef TOOLS_ENABLED
if (can_run && p_keep_state) {
_restore_old_static_data();
+ } else if (!can_run) {
+ // Initialize static variables with sane default values even if the constructor isn't called.
+ _static_default_init();
}
#endif
diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h
index 51267ecb84..f63b0da745 100644
--- a/modules/gdscript/gdscript.h
+++ b/modules/gdscript/gdscript.h
@@ -169,6 +169,9 @@ private:
GDScriptFunction *static_initializer = nullptr;
Error _static_init();
+#ifdef TOOLS_ENABLED
+ void _static_default_init(); // Initialize static variables with default values based on their types.
+#endif
int subclass_count = 0;
RBSet<Object *> instances;
diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp
index 1ed335fe99..09a037fd28 100644
--- a/modules/text_server_adv/text_server_adv.cpp
+++ b/modules/text_server_adv/text_server_adv.cpp
@@ -7342,6 +7342,16 @@ bool TextServerAdvanced::_is_valid_identifier(const String &p_string) const {
return true;
}
+bool TextServerAdvanced::_is_valid_letter(char32_t p_unicode) const {
+#ifndef ICU_STATIC_DATA
+ if (!icu_data_loaded) {
+ return TextServer::is_valid_letter(p_unicode);
+ }
+#endif
+
+ return u_isalpha(p_unicode);
+}
+
TextServerAdvanced::TextServerAdvanced() {
_insert_num_systems_lang();
_insert_feature_sets();
diff --git a/modules/text_server_adv/text_server_adv.h b/modules/text_server_adv/text_server_adv.h
index 1cd73a6999..7e29f984c1 100644
--- a/modules/text_server_adv/text_server_adv.h
+++ b/modules/text_server_adv/text_server_adv.h
@@ -988,6 +988,7 @@ public:
MODBIND1RC(String, strip_diacritics, const String &);
MODBIND1RC(bool, is_valid_identifier, const String &);
+ MODBIND1RC(bool, is_valid_letter, char32_t);
MODBIND2RC(String, string_to_upper, const String &, const String &);
MODBIND2RC(String, string_to_lower, const String &, const String &);