diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/object.cpp | 15 | ||||
-rw-r--r-- | core/object.h | 1 | ||||
-rw-r--r-- | core/script_language.cpp | 2 | ||||
-rw-r--r-- | core/script_language.h | 3 |
4 files changed, 18 insertions, 3 deletions
diff --git a/core/object.cpp b/core/object.cpp index 05e661baab..b30ae1f512 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -1929,6 +1929,13 @@ bool Object::has_script_instance_binding(int p_script_language_index) { return _script_instance_bindings[p_script_language_index] != NULL; } +void Object::set_script_instance_binding(int p_script_language_index, void *p_data) { +#ifdef DEBUG_ENABLED + CRASH_COND(_script_instance_bindings[p_script_language_index] != NULL); +#endif + _script_instance_bindings[p_script_language_index] = p_data; +} + Object::Object() { _class_ptr = NULL; @@ -1992,9 +1999,11 @@ Object::~Object() { _instance_ID = 0; _predelete_ok = 2; - for (int i = 0; i < MAX_SCRIPT_INSTANCE_BINDINGS; i++) { - if (_script_instance_bindings[i]) { - ScriptServer::get_language(i)->free_instance_binding_data(_script_instance_bindings[i]); + if (!ScriptServer::are_languages_finished()) { + for (int i = 0; i < MAX_SCRIPT_INSTANCE_BINDINGS; i++) { + if (_script_instance_bindings[i]) { + ScriptServer::get_language(i)->free_instance_binding_data(_script_instance_bindings[i]); + } } } } diff --git a/core/object.h b/core/object.h index 5bfef8a439..9a5217e3de 100644 --- a/core/object.h +++ b/core/object.h @@ -730,6 +730,7 @@ public: //used by script languages to store binding data void *get_script_instance_binding(int p_script_language_index); bool has_script_instance_binding(int p_script_language_index); + void set_script_instance_binding(int p_script_language_index, void *p_data); void clear_internal_resource_paths(); diff --git a/core/script_language.cpp b/core/script_language.cpp index 632fa3b336..2746c015d6 100644 --- a/core/script_language.cpp +++ b/core/script_language.cpp @@ -37,6 +37,7 @@ int ScriptServer::_language_count = 0; bool ScriptServer::scripting_enabled = true; bool ScriptServer::reload_scripts_on_save = false; +bool ScriptServer::languages_finished = false; ScriptEditRequestFunction ScriptServer::edit_request_func = NULL; void Script::_notification(int p_what) { @@ -130,6 +131,7 @@ void ScriptServer::finish_languages() { _languages[i]->finish(); } global_classes_clear(); + languages_finished = true; } void ScriptServer::set_reload_scripts_on_save(bool p_enable) { diff --git a/core/script_language.h b/core/script_language.h index b0f12dc291..2d35097692 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -54,6 +54,7 @@ class ScriptServer { static int _language_count; static bool scripting_enabled; static bool reload_scripts_on_save; + static bool languages_finished; struct GlobalScriptClass { StringName language; @@ -91,6 +92,8 @@ public: static void init_languages(); static void finish_languages(); + + static bool are_languages_finished() { return languages_finished; } }; class ScriptInstance; |