Mono: Fix crash on script load if the scripts domain isn't loaded

This commit is contained in:
Ignacio Etcheverry 2018-04-24 20:36:17 +02:00
parent 098c7ba4f9
commit 89e84185e8
1 changed files with 15 additions and 7 deletions

View File

@ -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,15 +2299,21 @@ 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.
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
} else { // just reload it normally
#endif
script->reload();
#ifdef TOOLS_ENABLED
}
#endif
if (r_error)
*r_error = OK;