summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/extension/gdextension.cpp10
-rw-r--r--core/extension/gdextension.h1
-rw-r--r--core/extension/gdextension_compat_hashes.cpp73
-rw-r--r--core/extension/gdextension_interface.h1
-rw-r--r--core/io/resource_format_binary.cpp38
-rw-r--r--core/math/expression.cpp10
-rw-r--r--core/object/object.compat.inc40
-rw-r--r--core/object/object.cpp1
-rw-r--r--core/object/object.h4
-rw-r--r--core/object/script_language.cpp17
-rw-r--r--core/object/script_language.h2
-rw-r--r--core/object/worker_thread_pool.cpp20
-rw-r--r--core/object/worker_thread_pool.h2
-rw-r--r--core/register_core_types.cpp8
-rw-r--r--core/string/string_name.cpp5
-rw-r--r--core/string/string_name.h3
-rw-r--r--core/string/translation.compat.inc41
-rw-r--r--core/string/translation.cpp1
-rw-r--r--core/string/translation.h4
-rw-r--r--core/string/translation_server.compat.inc38
-rw-r--r--core/string/translation_server.cpp1
-rw-r--r--core/string/translation_server.h4
22 files changed, 130 insertions, 194 deletions
diff --git a/core/extension/gdextension.cpp b/core/extension/gdextension.cpp
index d4b50facb2..7cba5cb161 100644
--- a/core/extension/gdextension.cpp
+++ b/core/extension/gdextension.cpp
@@ -262,7 +262,6 @@ void GDExtension::_register_extension_class(GDExtensionClassLibraryPtr p_library
p_extension_funcs->get_virtual_func, // GDExtensionClassGetVirtual get_virtual_func;
nullptr, // GDExtensionClassGetVirtualCallData get_virtual_call_data_func;
nullptr, // GDExtensionClassCallVirtualWithData call_virtual_func;
- p_extension_funcs->get_rid_func, // GDExtensionClassGetRID get_rid;
p_extension_funcs->class_userdata, // void *class_userdata;
};
@@ -270,6 +269,7 @@ void GDExtension::_register_extension_class(GDExtensionClassLibraryPtr p_library
p_extension_funcs->notification_func, // GDExtensionClassNotification notification_func;
p_extension_funcs->free_property_list_func, // GDExtensionClassFreePropertyList free_property_list_func;
p_extension_funcs->create_instance_func, // GDExtensionClassCreateInstance create_instance_func;
+ p_extension_funcs->get_rid_func, // GDExtensionClassGetRID get_rid;
};
_register_extension_class_internal(p_library, p_class_name, p_parent_class_name, &class_info4, &legacy);
}
@@ -297,7 +297,6 @@ void GDExtension::_register_extension_class2(GDExtensionClassLibraryPtr p_librar
p_extension_funcs->get_virtual_func, // GDExtensionClassGetVirtual get_virtual_func;
p_extension_funcs->get_virtual_call_data_func, // GDExtensionClassGetVirtualCallData get_virtual_call_data_func;
p_extension_funcs->call_virtual_with_data_func, // GDExtensionClassCallVirtualWithData call_virtual_func;
- p_extension_funcs->get_rid_func, // GDExtensionClassGetRID get_rid;
p_extension_funcs->class_userdata, // void *class_userdata;
};
@@ -305,6 +304,7 @@ void GDExtension::_register_extension_class2(GDExtensionClassLibraryPtr p_librar
nullptr, // GDExtensionClassNotification notification_func;
p_extension_funcs->free_property_list_func, // GDExtensionClassFreePropertyList free_property_list_func;
p_extension_funcs->create_instance_func, // GDExtensionClassCreateInstance create_instance_func;
+ p_extension_funcs->get_rid_func, // GDExtensionClassGetRID get_rid;
};
_register_extension_class_internal(p_library, p_class_name, p_parent_class_name, &class_info4, &legacy);
}
@@ -332,7 +332,6 @@ void GDExtension::_register_extension_class3(GDExtensionClassLibraryPtr p_librar
p_extension_funcs->get_virtual_func, // GDExtensionClassGetVirtual get_virtual_func;
p_extension_funcs->get_virtual_call_data_func, // GDExtensionClassGetVirtualCallData get_virtual_call_data_func;
p_extension_funcs->call_virtual_with_data_func, // GDExtensionClassCallVirtualWithData call_virtual_func;
- p_extension_funcs->get_rid_func, // GDExtensionClassGetRID get_rid;
p_extension_funcs->class_userdata, // void *class_userdata;
};
@@ -340,6 +339,7 @@ void GDExtension::_register_extension_class3(GDExtensionClassLibraryPtr p_librar
nullptr, // GDExtensionClassNotification notification_func;
nullptr, // GDExtensionClassFreePropertyList free_property_list_func;
p_extension_funcs->create_instance_func, // GDExtensionClassCreateInstance2 create_instance_func;
+ p_extension_funcs->get_rid_func, // GDExtensionClassGetRID get_rid;
};
_register_extension_class_internal(p_library, p_class_name, p_parent_class_name, &class_info4, &legacy);
}
@@ -355,7 +355,7 @@ void GDExtension::_register_extension_class_internal(GDExtensionClassLibraryPtr
StringName class_name = *reinterpret_cast<const StringName *>(p_class_name);
StringName parent_class_name = *reinterpret_cast<const StringName *>(p_parent_class_name);
- ERR_FAIL_COND_MSG(!String(class_name).is_valid_ascii_identifier(), "Attempt to register extension class '" + class_name + "', which is not a valid class identifier.");
+ ERR_FAIL_COND_MSG(!String(class_name).is_valid_unicode_identifier(), "Attempt to register extension class '" + class_name + "', which is not a valid class identifier.");
ERR_FAIL_COND_MSG(ClassDB::class_exists(class_name), "Attempt to register extension class '" + class_name + "', which appears to be already registered.");
Extension *parent_extension = nullptr;
@@ -427,6 +427,7 @@ void GDExtension::_register_extension_class_internal(GDExtensionClassLibraryPtr
extension->gdextension.notification = p_deprecated_funcs->notification_func;
extension->gdextension.free_property_list = p_deprecated_funcs->free_property_list_func;
extension->gdextension.create_instance = p_deprecated_funcs->create_instance_func;
+ extension->gdextension.get_rid = p_deprecated_funcs->get_rid_func;
}
#endif // DISABLE_DEPRECATED
extension->gdextension.notification2 = p_extension_funcs->notification_func;
@@ -440,7 +441,6 @@ void GDExtension::_register_extension_class_internal(GDExtensionClassLibraryPtr
extension->gdextension.get_virtual = p_extension_funcs->get_virtual_func;
extension->gdextension.get_virtual_call_data = p_extension_funcs->get_virtual_call_data_func;
extension->gdextension.call_virtual_with_data = p_extension_funcs->call_virtual_with_data_func;
- extension->gdextension.get_rid = p_extension_funcs->get_rid_func;
extension->gdextension.reloadable = self->reloadable;
#ifdef TOOLS_ENABLED
diff --git a/core/extension/gdextension.h b/core/extension/gdextension.h
index 7bb4294909..706bc7e189 100644
--- a/core/extension/gdextension.h
+++ b/core/extension/gdextension.h
@@ -71,6 +71,7 @@ class GDExtension : public Resource {
GDExtensionClassNotification notification_func = nullptr;
GDExtensionClassFreePropertyList free_property_list_func = nullptr;
GDExtensionClassCreateInstance create_instance_func = nullptr;
+ GDExtensionClassGetRID get_rid_func = nullptr;
#endif // DISABLE_DEPRECATED
};
diff --git a/core/extension/gdextension_compat_hashes.cpp b/core/extension/gdextension_compat_hashes.cpp
index ebbf795070..b07f5b1858 100644
--- a/core/extension/gdextension_compat_hashes.cpp
+++ b/core/extension/gdextension_compat_hashes.cpp
@@ -103,6 +103,14 @@ void GDExtensionCompatHashes::initialize() {
mappings.insert("AcceptDialog", {
{ "add_button", 4158837846, 3328440682 },
});
+ mappings.insert("AnimatedSprite2D", {
+ { "play", 2372066587, 3269405555 },
+ { "play_backwards", 1421762485, 3323268493 },
+ });
+ mappings.insert("AnimatedSprite3D", {
+ { "play", 2372066587, 3269405555 },
+ { "play_backwards", 1421762485, 3323268493 },
+ });
mappings.insert("Animation", {
{ "add_track", 2393815928, 3843682357 },
{ "track_insert_key", 1985425300, 808952278 },
@@ -146,6 +154,12 @@ void GDExtensionCompatHashes::initialize() {
{ "travel", 3683006648, 3823612587 },
{ "start", 3683006648, 3823612587 },
});
+ mappings.insert("AnimationPlayer", {
+ { "play", 3697947785, 3118260607 },
+ { "play", 2221377757, 3118260607 },
+ { "play_backwards", 3890664824, 2787282401 },
+ { "play_with_capture", 3180464118, 1572969103 },
+ });
mappings.insert("ArrayMesh", {
{ "add_surface_from_arrays", 172284304, 1796411378 },
});
@@ -247,13 +261,20 @@ void GDExtensionCompatHashes::initialize() {
});
mappings.insert("DisplayServer", {
{ "global_menu_add_submenu_item", 3806306913, 2828985934 },
- { "global_menu_add_item", 3415468211, 3401266716 },
- { "global_menu_add_check_item", 3415468211, 3401266716 },
- { "global_menu_add_icon_item", 1700867534, 4245856523 },
- { "global_menu_add_icon_check_item", 1700867534, 4245856523 },
- { "global_menu_add_radio_check_item", 3415468211, 3401266716 },
- { "global_menu_add_icon_radio_check_item", 1700867534, 4245856523 },
- { "global_menu_add_multistate_item", 635750054, 3431222859 },
+ { "global_menu_add_item", 3415468211, 3616842746 },
+ { "global_menu_add_item", 3401266716, 3616842746 },
+ { "global_menu_add_check_item", 3415468211, 3616842746 },
+ { "global_menu_add_check_item", 3401266716, 3616842746 },
+ { "global_menu_add_icon_item", 1700867534, 3867083847 },
+ { "global_menu_add_icon_item", 4245856523, 3867083847 },
+ { "global_menu_add_icon_check_item", 1700867534, 3867083847 },
+ { "global_menu_add_icon_check_item", 4245856523, 3867083847 },
+ { "global_menu_add_radio_check_item", 3415468211, 3616842746 },
+ { "global_menu_add_radio_check_item", 3401266716, 3616842746 },
+ { "global_menu_add_icon_radio_check_item", 1700867534, 3867083847 },
+ { "global_menu_add_icon_radio_check_item", 4245856523, 3867083847 },
+ { "global_menu_add_multistate_item", 635750054, 3297554655 },
+ { "global_menu_add_multistate_item", 3431222859, 3297554655 },
{ "global_menu_add_separator", 1041533178, 3214812433 },
{ "tts_speak", 3741216677, 903992738 },
{ "is_touchscreen_available", 4162880507, 3323674545 },
@@ -286,6 +307,12 @@ void GDExtensionCompatHashes::initialize() {
{ "virtual_keyboard_show", 860410478, 3042891259 },
#endif
});
+ mappings.insert("EditorExportPlatform", {
+ { "export_project_files", 425454869, 1063735070 },
+ });
+ mappings.insert("EditorProperty", {
+ { "emit_changed", 3069422438, 1822500399 },
+ });
mappings.insert("ENetConnection", {
{ "create_host_bound", 866250949, 1515002313 },
{ "connect_to_host", 385984708, 2171300490 },
@@ -453,18 +480,35 @@ void GDExtensionCompatHashes::initialize() {
mappings.insert("MultiplayerAPI", {
{ "rpc", 1833408346, 2077486355 },
});
+ mappings.insert("NativeMenu", {
+ { "add_item", 2553375659, 980552939 },
+ { "add_check_item", 2553375659, 980552939 },
+ { "add_icon_item", 2987595282, 1372188274 },
+ { "add_icon_check_item", 2987595282, 1372188274 },
+ { "add_radio_check_item", 2553375659, 980552939 },
+ { "add_icon_radio_check_item", 2987595282, 1372188274 },
+ { "add_multistate_item", 1558592568, 2674635658 },
+ });
mappings.insert("NavigationMeshGenerator", {
- { "parse_source_geometry_data", 3703028813, 685862123 },
- { "bake_from_source_geometry_data", 3669016597, 2469318639 },
+ { "parse_source_geometry_data", 3703028813, 3172802542 },
+ { "parse_source_geometry_data", 685862123, 3172802542 },
+ { "bake_from_source_geometry_data", 3669016597, 1286748856 },
+ { "bake_from_source_geometry_data", 2469318639, 1286748856 },
});
mappings.insert("NavigationServer2D", {
{ "map_get_path", 56240621, 3146466012 },
+ { "parse_source_geometry_data", 1176164995, 1766905497 },
+ { "bake_from_source_geometry_data", 2909414286, 2179660022 },
+ { "bake_from_source_geometry_data_async", 2909414286, 2179660022 },
});
mappings.insert("NavigationServer3D", {
{ "map_get_path", 2121045993, 1187418690 },
- { "parse_source_geometry_data", 3703028813, 685862123 },
- { "bake_from_source_geometry_data", 3669016597, 2469318639 },
- { "bake_from_source_geometry_data_async", 3669016597, 2469318639 },
+ { "parse_source_geometry_data", 3703028813, 3172802542 },
+ { "parse_source_geometry_data", 685862123, 3172802542 },
+ { "bake_from_source_geometry_data", 3669016597, 1286748856 },
+ { "bake_from_source_geometry_data", 2469318639, 1286748856 },
+ { "bake_from_source_geometry_data_async", 3669016597, 1286748856 },
+ { "bake_from_source_geometry_data_async", 2469318639, 1286748856 },
});
mappings.insert("Node", {
{ "add_child", 3070154285, 3863233950 },
@@ -631,6 +675,11 @@ void GDExtensionCompatHashes::initialize() {
mappings.insert("ProjectSettings", {
{ "load_resource_pack", 3001721055, 708980503 },
});
+ mappings.insert("RDShaderFile", {
+ { "bake_from_source_geometry_data_async", 2469318639, 1286748856 },
+ { "set_bytecode", 1558064255, 1526857008 },
+ { "get_spirv", 3340165340, 2689310080 },
+ });
mappings.insert("RegEx", {
{ "search", 4087180739, 3365977994 },
{ "search_all", 3354100289, 849021363 },
diff --git a/core/extension/gdextension_interface.h b/core/extension/gdextension_interface.h
index d3132baf1b..8eb8a2ed33 100644
--- a/core/extension/gdextension_interface.h
+++ b/core/extension/gdextension_interface.h
@@ -392,7 +392,6 @@ typedef struct {
GDExtensionClassGetVirtualCallData get_virtual_call_data_func;
// Used to call virtual functions when `get_virtual_call_data_func` is not null.
GDExtensionClassCallVirtualWithData call_virtual_with_data_func;
- GDExtensionClassGetRID get_rid_func;
void *class_userdata; // Per-class user data, later accessible in instance bindings.
} GDExtensionClassCreationInfo4;
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 41a8a569d0..b4826c356e 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -845,27 +845,29 @@ Error ResourceLoaderBinary::load() {
}
}
- if (value.get_type() == Variant::ARRAY) {
- Array set_array = value;
- bool is_get_valid = false;
- Variant get_value = res->get(name, &is_get_valid);
- if (is_get_valid && get_value.get_type() == Variant::ARRAY) {
- Array get_array = get_value;
- if (!set_array.is_same_typed(get_array)) {
- value = Array(set_array, get_array.get_typed_builtin(), get_array.get_typed_class_name(), get_array.get_typed_script());
+ if (ClassDB::has_property(res->get_class_name(), name)) {
+ if (value.get_type() == Variant::ARRAY) {
+ Array set_array = value;
+ bool is_get_valid = false;
+ Variant get_value = res->get(name, &is_get_valid);
+ if (is_get_valid && get_value.get_type() == Variant::ARRAY) {
+ Array get_array = get_value;
+ if (!set_array.is_same_typed(get_array)) {
+ value = Array(set_array, get_array.get_typed_builtin(), get_array.get_typed_class_name(), get_array.get_typed_script());
+ }
}
}
- }
- if (value.get_type() == Variant::DICTIONARY) {
- Dictionary set_dict = value;
- bool is_get_valid = false;
- Variant get_value = res->get(name, &is_get_valid);
- if (is_get_valid && get_value.get_type() == Variant::DICTIONARY) {
- Dictionary get_dict = get_value;
- if (!set_dict.is_same_typed(get_dict)) {
- value = Dictionary(set_dict, get_dict.get_typed_key_builtin(), get_dict.get_typed_key_class_name(), get_dict.get_typed_key_script(),
- get_dict.get_typed_value_builtin(), get_dict.get_typed_value_class_name(), get_dict.get_typed_value_script());
+ if (value.get_type() == Variant::DICTIONARY) {
+ Dictionary set_dict = value;
+ bool is_get_valid = false;
+ Variant get_value = res->get(name, &is_get_valid);
+ if (is_get_valid && get_value.get_type() == Variant::DICTIONARY) {
+ Dictionary get_dict = get_value;
+ if (!set_dict.is_same_typed(get_dict)) {
+ value = Dictionary(set_dict, get_dict.get_typed_key_builtin(), get_dict.get_typed_key_class_name(), get_dict.get_typed_key_script(),
+ get_dict.get_typed_value_builtin(), get_dict.get_typed_value_class_name(), get_dict.get_typed_value_script());
+ }
}
}
}
diff --git a/core/math/expression.cpp b/core/math/expression.cpp
index 636c2c16bf..0692ece1e6 100644
--- a/core/math/expression.cpp
+++ b/core/math/expression.cpp
@@ -30,12 +30,7 @@
#include "expression.h"
-#include "core/io/marshalls.h"
-#include "core/math/math_funcs.h"
#include "core/object/class_db.h"
-#include "core/object/ref_counted.h"
-#include "core/os/os.h"
-#include "core/variant/variant_parser.h"
Error Expression::_get_token(Token &r_token) {
while (true) {
@@ -392,7 +387,6 @@ Error Expression::_get_token(Token &r_token) {
if (is_digit(c)) {
} else if (c == 'e') {
reading = READING_EXP;
-
} else {
reading = READING_DONE;
}
@@ -419,7 +413,9 @@ Error Expression::_get_token(Token &r_token) {
is_first_char = false;
}
- str_ofs--;
+ if (c != 0) {
+ str_ofs--;
+ }
r_token.type = TK_CONSTANT;
diff --git a/core/object/object.compat.inc b/core/object/object.compat.inc
deleted file mode 100644
index bf1e99fc9b..0000000000
--- a/core/object/object.compat.inc
+++ /dev/null
@@ -1,40 +0,0 @@
-/**************************************************************************/
-/* object.compat.inc */
-/**************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/**************************************************************************/
-/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/**************************************************************************/
-
-#ifndef DISABLE_DEPRECATED
-
-#include "core/object/class_db.h"
-
-void Object::_bind_compatibility_methods() {
- ClassDB::bind_compatibility_method(D_METHOD("tr", "message", "context"), &Object::tr, DEFVAL(""));
- ClassDB::bind_compatibility_method(D_METHOD("tr_n", "message", "plural_message", "n", "context"), &Object::tr_n, DEFVAL(""));
-}
-
-#endif
diff --git a/core/object/object.cpp b/core/object/object.cpp
index d6b7d7a7fe..000d5328b4 100644
--- a/core/object/object.cpp
+++ b/core/object/object.cpp
@@ -29,7 +29,6 @@
/**************************************************************************/
#include "object.h"
-#include "object.compat.inc"
#include "core/extension/gdextension_manager.h"
#include "core/io/resource.h"
diff --git a/core/object/object.h b/core/object/object.h
index 19e6fc5d47..6d22f320af 100644
--- a/core/object/object.h
+++ b/core/object/object.h
@@ -693,11 +693,7 @@ protected:
virtual void _notificationv(int p_notification, bool p_reversed) {}
static void _bind_methods();
-#ifndef DISABLE_DEPRECATED
- static void _bind_compatibility_methods();
-#else
static void _bind_compatibility_methods() {}
-#endif
bool _set(const StringName &p_name, const Variant &p_property) { return false; };
bool _get(const StringName &p_name, Variant &r_property) const { return false; };
void _get_property_list(List<PropertyInfo> *p_list) const {};
diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp
index 57e5195137..d5b7bc768d 100644
--- a/core/object/script_language.cpp
+++ b/core/object/script_language.cpp
@@ -41,6 +41,7 @@ ScriptLanguage *ScriptServer::_languages[MAX_LANGUAGES];
int ScriptServer::_language_count = 0;
bool ScriptServer::languages_ready = false;
Mutex ScriptServer::languages_mutex;
+thread_local bool ScriptServer::thread_entered = false;
bool ScriptServer::scripting_enabled = true;
bool ScriptServer::reload_scripts_on_save = false;
@@ -326,6 +327,10 @@ bool ScriptServer::are_languages_initialized() {
return languages_ready;
}
+bool ScriptServer::thread_is_entered() {
+ return thread_entered;
+}
+
void ScriptServer::set_reload_scripts_on_save(bool p_enable) {
reload_scripts_on_save = p_enable;
}
@@ -335,6 +340,10 @@ bool ScriptServer::is_reload_scripts_on_save_enabled() {
}
void ScriptServer::thread_enter() {
+ if (thread_entered) {
+ return;
+ }
+
MutexLock lock(languages_mutex);
if (!languages_ready) {
return;
@@ -342,9 +351,15 @@ void ScriptServer::thread_enter() {
for (int i = 0; i < _language_count; i++) {
_languages[i]->thread_enter();
}
+
+ thread_entered = true;
}
void ScriptServer::thread_exit() {
+ if (!thread_entered) {
+ return;
+ }
+
MutexLock lock(languages_mutex);
if (!languages_ready) {
return;
@@ -352,6 +367,8 @@ void ScriptServer::thread_exit() {
for (int i = 0; i < _language_count; i++) {
_languages[i]->thread_exit();
}
+
+ thread_entered = false;
}
HashMap<StringName, ScriptServer::GlobalScriptClass> ScriptServer::global_classes;
diff --git a/core/object/script_language.h b/core/object/script_language.h
index e38c344ae5..d9e2ab1d3c 100644
--- a/core/object/script_language.h
+++ b/core/object/script_language.h
@@ -54,6 +54,7 @@ class ScriptServer {
static int _language_count;
static bool languages_ready;
static Mutex languages_mutex;
+ static thread_local bool thread_entered;
static bool scripting_enabled;
static bool reload_scripts_on_save;
@@ -101,6 +102,7 @@ public:
static void init_languages();
static void finish_languages();
static bool are_languages_initialized();
+ static bool thread_is_entered();
};
class PlaceHolderScriptInstance;
diff --git a/core/object/worker_thread_pool.cpp b/core/object/worker_thread_pool.cpp
index fe7bbd474c..cf396c2676 100644
--- a/core/object/worker_thread_pool.cpp
+++ b/core/object/worker_thread_pool.cpp
@@ -63,17 +63,14 @@ void WorkerThreadPool::_process_task(Task *p_task) {
// Tasks must start with these at default values. They are free to set-and-forget otherwise.
set_current_thread_safe_for_nodes(false);
MessageQueue::set_thread_singleton_override(nullptr);
+
// Since the WorkerThreadPool is started before the script server,
// its pre-created threads can't have ScriptServer::thread_enter() called on them early.
// Therefore, we do it late at the first opportunity, so in case the task
// about to be run uses scripting, guarantees are held.
+ ScriptServer::thread_enter();
+
task_mutex.lock();
- if (!curr_thread.ready_for_scripting && ScriptServer::are_languages_initialized()) {
- task_mutex.unlock();
- ScriptServer::thread_enter();
- task_mutex.lock();
- curr_thread.ready_for_scripting = true;
- }
p_task->pool_thread_index = pool_thread_index;
prev_task = curr_thread.current_task;
curr_thread.current_task = p_task;
@@ -326,6 +323,8 @@ WorkerThreadPool::TaskID WorkerThreadPool::add_native_task(void (*p_func)(void *
}
WorkerThreadPool::TaskID WorkerThreadPool::_add_task(const Callable &p_callable, void (*p_func)(void *), void *p_userdata, BaseTemplateUserdata *p_template_userdata, bool p_high_priority, const String &p_description) {
+ ERR_FAIL_COND_V_MSG(threads.is_empty(), INVALID_TASK_ID, "Can't add a task because the WorkerThreadPool is either not initialized yet or already terminated.");
+
task_mutex.lock();
// Get a free task
Task *task = task_allocator.alloc();
@@ -514,6 +513,12 @@ void WorkerThreadPool::yield() {
int th_index = get_thread_index();
ERR_FAIL_COND_MSG(th_index == -1, "This function can only be called from a worker thread.");
_wait_collaboratively(&threads[th_index], ThreadData::YIELDING);
+
+ // If this long-lived task started before the scripting server was initialized,
+ // now is a good time to have scripting languages ready for the current thread.
+ // Otherwise, such a piece of setup won't happen unless another task has been
+ // run during the collaborative wait.
+ ScriptServer::thread_enter();
}
void WorkerThreadPool::notify_yield_over(TaskID p_task_id) {
@@ -538,6 +543,7 @@ void WorkerThreadPool::notify_yield_over(TaskID p_task_id) {
}
WorkerThreadPool::GroupID WorkerThreadPool::_add_group_task(const Callable &p_callable, void (*p_func)(void *, uint32_t), void *p_userdata, BaseTemplateUserdata *p_template_userdata, int p_elements, int p_tasks, bool p_high_priority, const String &p_description) {
+ ERR_FAIL_COND_V_MSG(threads.is_empty(), INVALID_TASK_ID, "Can't add a group task because the WorkerThreadPool is either not initialized yet or already terminated.");
ERR_FAIL_COND_V(p_elements < 0, INVALID_TASK_ID);
if (p_tasks < 0) {
p_tasks = MAX(1u, threads.size());
@@ -749,5 +755,5 @@ WorkerThreadPool::WorkerThreadPool() {
}
WorkerThreadPool::~WorkerThreadPool() {
- finish();
+ DEV_ASSERT(threads.size() == 0 && "finish() hasn't been called!");
}
diff --git a/core/object/worker_thread_pool.h b/core/object/worker_thread_pool.h
index 5be4f20927..6374dbe8c7 100644
--- a/core/object/worker_thread_pool.h
+++ b/core/object/worker_thread_pool.h
@@ -112,7 +112,6 @@ private:
uint32_t index = 0;
Thread thread;
- bool ready_for_scripting : 1;
bool signaled : 1;
bool yield_is_over : 1;
Task *current_task = nullptr;
@@ -120,7 +119,6 @@ private:
ConditionVariable cond_var;
ThreadData() :
- ready_for_scripting(false),
signaled(false),
yield_is_over(false) {}
};
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index c866ff0415..220ed9da31 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -107,8 +107,6 @@ static Time *_time = nullptr;
static core_bind::Geometry2D *_geometry_2d = nullptr;
static core_bind::Geometry3D *_geometry_3d = nullptr;
-static WorkerThreadPool *worker_thread_pool = nullptr;
-
extern Mutex _global_mutex;
static GDExtensionManager *gdextension_manager = nullptr;
@@ -297,8 +295,6 @@ void register_core_types() {
GDREGISTER_NATIVE_STRUCT(AudioFrame, "float left;float right");
GDREGISTER_NATIVE_STRUCT(ScriptLanguageExtensionProfilingInfo, "StringName signature;uint64_t call_count;uint64_t total_time;uint64_t self_time");
- worker_thread_pool = memnew(WorkerThreadPool);
-
OS::get_singleton()->benchmark_end_measure("Core", "Register Types");
}
@@ -349,7 +345,7 @@ void register_core_singletons() {
Engine::get_singleton()->add_singleton(Engine::Singleton("Time", Time::get_singleton()));
Engine::get_singleton()->add_singleton(Engine::Singleton("GDExtensionManager", GDExtensionManager::get_singleton()));
Engine::get_singleton()->add_singleton(Engine::Singleton("ResourceUID", ResourceUID::get_singleton()));
- Engine::get_singleton()->add_singleton(Engine::Singleton("WorkerThreadPool", worker_thread_pool));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("WorkerThreadPool", WorkerThreadPool::get_singleton()));
OS::get_singleton()->benchmark_end_measure("Core", "Register Singletons");
}
@@ -382,8 +378,6 @@ void unregister_core_types() {
// Destroy singletons in reverse order to ensure dependencies are not broken.
- memdelete(worker_thread_pool);
-
memdelete(_engine_debugger);
memdelete(_marshalls);
memdelete(_classdb);
diff --git a/core/string/string_name.cpp b/core/string/string_name.cpp
index 0294dbfbbc..dff19b3a41 100644
--- a/core/string/string_name.cpp
+++ b/core/string/string_name.cpp
@@ -162,6 +162,11 @@ void StringName::unref() {
_data = nullptr;
}
+uint32_t StringName::get_empty_hash() {
+ static uint32_t empty_hash = String::hash("");
+ return empty_hash;
+}
+
bool StringName::operator==(const String &p_name) const {
if (_data) {
return _data->operator==(p_name);
diff --git a/core/string/string_name.h b/core/string/string_name.h
index 288e2c7520..d4b70d311d 100644
--- a/core/string/string_name.h
+++ b/core/string/string_name.h
@@ -83,6 +83,7 @@ class StringName {
static inline Mutex mutex;
static void setup();
static void cleanup();
+ static uint32_t get_empty_hash();
static inline bool configured = false;
#ifdef DEBUG_ENABLED
struct DebugSortReferences {
@@ -139,7 +140,7 @@ public:
if (_data) {
return _data->hash;
} else {
- return 0;
+ return get_empty_hash();
}
}
_FORCE_INLINE_ const void *data_unique_pointer() const {
diff --git a/core/string/translation.compat.inc b/core/string/translation.compat.inc
deleted file mode 100644
index 68bd1831e4..0000000000
--- a/core/string/translation.compat.inc
+++ /dev/null
@@ -1,41 +0,0 @@
-/**************************************************************************/
-/* translation.compat.inc */
-/**************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/**************************************************************************/
-/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/**************************************************************************/
-
-#ifndef DISABLE_DEPRECATED
-
-void Translation::_bind_compatibility_methods() {
- ClassDB::bind_compatibility_method(D_METHOD("add_message", "src_message", "xlated_message", "context"), &Translation::add_message, DEFVAL(""));
- ClassDB::bind_compatibility_method(D_METHOD("add_plural_message", "src_message", "xlated_messages", "context"), &Translation::add_plural_message, DEFVAL(""));
- ClassDB::bind_compatibility_method(D_METHOD("get_message", "src_message", "context"), &Translation::get_message, DEFVAL(""));
- ClassDB::bind_compatibility_method(D_METHOD("get_plural_message", "src_message", "src_plural_message", "n", "context"), &Translation::get_plural_message, DEFVAL(""));
- ClassDB::bind_compatibility_method(D_METHOD("erase_message", "src_message", "context"), &Translation::erase_message, DEFVAL(""));
-}
-
-#endif
diff --git a/core/string/translation.cpp b/core/string/translation.cpp
index 33d4a1bcde..020949371f 100644
--- a/core/string/translation.cpp
+++ b/core/string/translation.cpp
@@ -29,7 +29,6 @@
/**************************************************************************/
#include "translation.h"
-#include "translation.compat.inc"
#include "core/os/os.h"
#include "core/os/thread.h"
diff --git a/core/string/translation.h b/core/string/translation.h
index 2c5baae8b7..4e8cffc90c 100644
--- a/core/string/translation.h
+++ b/core/string/translation.h
@@ -51,10 +51,6 @@ class Translation : public Resource {
protected:
static void _bind_methods();
-#ifndef DISABLE_DEPRECATED
- static void _bind_compatibility_methods();
-#endif
-
GDVIRTUAL2RC(StringName, _get_message, StringName, StringName);
GDVIRTUAL4RC(StringName, _get_plural_message, StringName, StringName, int, StringName);
diff --git a/core/string/translation_server.compat.inc b/core/string/translation_server.compat.inc
deleted file mode 100644
index 9d1ee8b9df..0000000000
--- a/core/string/translation_server.compat.inc
+++ /dev/null
@@ -1,38 +0,0 @@
-/**************************************************************************/
-/* translation_server.compat.inc */
-/**************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/**************************************************************************/
-/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/**************************************************************************/
-
-#ifndef DISABLE_DEPRECATED
-
-void TranslationServer::_bind_compatibility_methods() {
- ClassDB::bind_compatibility_method(D_METHOD("translate", "message", "context"), &TranslationServer::translate, DEFVAL(""));
- ClassDB::bind_compatibility_method(D_METHOD("translate_plural", "message", "plural_message", "n", "context"), &TranslationServer::translate_plural, DEFVAL(""));
-}
-
-#endif
diff --git a/core/string/translation_server.cpp b/core/string/translation_server.cpp
index 4ac79ad10a..d4aa152340 100644
--- a/core/string/translation_server.cpp
+++ b/core/string/translation_server.cpp
@@ -29,7 +29,6 @@
/**************************************************************************/
#include "translation_server.h"
-#include "translation_server.compat.inc"
#include "core/config/project_settings.h"
#include "core/io/resource_loader.h"
diff --git a/core/string/translation_server.h b/core/string/translation_server.h
index ebe81d9712..bb285ab19c 100644
--- a/core/string/translation_server.h
+++ b/core/string/translation_server.h
@@ -74,10 +74,6 @@ class TranslationServer : public Object {
static void _bind_methods();
-#ifndef DISABLE_DEPRECATED
- static void _bind_compatibility_methods();
-#endif
-
struct LocaleScriptInfo {
String name;
String script;