1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-20 14:45:44 +00:00

C# script reload fixed

Co-authored-by: Michael Bickel <mib@developium.net>
(cherry picked from commit 84a218d346)
This commit is contained in:
Germanrc
2021-09-21 01:09:39 +02:00
committed by Rémi Verschelde
parent 96d418cb94
commit aa679b2fe0
2 changed files with 8 additions and 7 deletions

View File

@@ -2730,6 +2730,7 @@ void CSharpScript::_clear() {
tool = false; tool = false;
valid = false; valid = false;
reload_invalidated = true;
base = NULL; base = NULL;
native = NULL; native = NULL;
@@ -2843,6 +2844,7 @@ void CSharpScript::initialize_for_managed_type(Ref<CSharpScript> p_script, GDMon
p_script->valid = true; p_script->valid = true;
p_script->tool = p_script->script_class->has_attribute(CACHED_CLASS(ToolAttribute)); p_script->tool = p_script->script_class->has_attribute(CACHED_CLASS(ToolAttribute));
p_script->reload_invalidated = false;
if (!p_script->tool) { if (!p_script->tool) {
GDMonoClass *nesting_class = p_script->script_class->get_nesting_class(); GDMonoClass *nesting_class = p_script->script_class->get_nesting_class();
@@ -3153,14 +3155,12 @@ MethodInfo CSharpScript::get_method_info(const StringName &p_method) const {
} }
Error CSharpScript::reload(bool p_keep_state) { Error CSharpScript::reload(bool p_keep_state) {
if (!reload_invalidated) {
bool has_instances; return OK;
{
MutexLock lock(CSharpLanguage::get_singleton()->script_instances_mutex);
has_instances = instances.size();
} }
// In the case of C#, reload doesn't really do any script reloading.
ERR_FAIL_COND_V(!p_keep_state && has_instances, ERR_ALREADY_IN_USE); // That's done separately via domain reloading.
reload_invalidated = false;
GD_MONO_SCOPE_THREAD_ATTACH; GD_MONO_SCOPE_THREAD_ATTACH;

View File

@@ -75,6 +75,7 @@ class CSharpScript : public Script {
bool tool; bool tool;
bool valid; bool valid;
bool reload_invalidated;
bool builtin; bool builtin;