diff options
| author | Ignacio Etcheverry | 2018-04-24 20:36:17 +0200 |
|---|---|---|
| committer | Hein-Pieter van Braam | 2018-04-28 22:59:11 +0200 |
| commit | 736d8db0079b484b1f21819dd351a50e2ed0e0bc (patch) | |
| tree | 128289839738d8cb72a6d574168e7261fb93fd9b /modules/mono | |
| parent | 1e8ff7460a8c4adbb4c28bc3b6ade25224c74154 (diff) | |
| download | godot-736d8db0079b484b1f21819dd351a50e2ed0e0bc.tar.gz godot-736d8db0079b484b1f21819dd351a50e2ed0e0bc.tar.zst godot-736d8db0079b484b1f21819dd351a50e2ed0e0bc.zip | |
Mono: Fix crash on script load if the scripts domain isn't loaded
(cherry picked from commit 89e84185e8cbd08531ae33554cf78ffba692cf7a)
Diffstat (limited to 'modules/mono')
| -rw-r--r-- | modules/mono/csharp_script.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 1d0afa7f2..254079820 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -2288,7 +2288,9 @@ RES ResourceFormatLoaderCSharpScript::load(const String &p_path, const String &p CRASH_COND(mono_domain_get() == NULL); #endif -#else +#endif + +#ifdef TOOLS_ENABLED if (Engine::get_singleton()->is_editor_hint() && mono_domain_get() == NULL) { CRASH_COND(Thread::get_caller_id() == Thread::get_main_id()); @@ -2297,14 +2299,20 @@ RES ResourceFormatLoaderCSharpScript::load(const String &p_path, const String &p // because this may be called by one of the editor's worker threads. // Attach this thread temporarily to reload the script. - MonoThread *mono_thread = mono_thread_attach(SCRIPTS_DOMAIN); - CRASH_COND(mono_thread == NULL); + if (SCRIPTS_DOMAIN) { + MonoThread *mono_thread = mono_thread_attach(SCRIPTS_DOMAIN); + CRASH_COND(mono_thread == NULL); + script->reload(); + mono_thread_detach(mono_thread); + } + + } else { // just reload it normally +#endif script->reload(); - mono_thread_detach(mono_thread); - } else // just reload it normally +#ifdef TOOLS_ENABLED + } #endif - script->reload(); if (r_error) *r_error = OK; |
