summaryrefslogtreecommitdiff
path: root/modules/mono
diff options
context:
space:
mode:
authorIgnacio Roldán Etcheverry <neikeq@users.noreply.github.com>2022-01-16 11:56:39 +0100
committerGitHub <noreply@github.com>2022-01-16 11:56:39 +0100
commite527687e1eaefd711b60cfdd0d4bd064a01dde80 (patch)
tree9ac18fb13ac7950abc482fd3cd732e89362fd325 /modules/mono
parenta27b85378ba75bacd9730e609f6068a5fd73484e (diff)
parent4a339dc8fdd6429b50cbf0861dc011db23accc63 (diff)
Merge pull request #55679 from raulsntos/script_reload_fix
C# scripts reload in editor fixed
Diffstat (limited to 'modules/mono')
-rw-r--r--modules/mono/csharp_script.cpp12
-rw-r--r--modules/mono/csharp_script.h1
2 files changed, 8 insertions, 5 deletions
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 3d02f638ec..9d416dcfce 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -2995,6 +2995,7 @@ void CSharpScript::initialize_for_managed_type(Ref<CSharpScript> p_script, GDMon
CRASH_COND(p_script->native == nullptr);
p_script->valid = true;
+ p_script->reload_invalidated = false;
update_script_class_info(p_script);
@@ -3351,13 +3352,13 @@ MethodInfo CSharpScript::get_method_info(const StringName &p_method) const {
}
Error CSharpScript::reload(bool p_keep_state) {
- bool has_instances;
- {
- MutexLock lock(CSharpLanguage::get_singleton()->script_instances_mutex);
- has_instances = instances.size();
+ if (!reload_invalidated) {
+ return OK;
}
- ERR_FAIL_COND_V(!p_keep_state && has_instances, ERR_ALREADY_IN_USE);
+ // In the case of C#, reload doesn't really do any script reloading.
+ // That's done separately via domain reloading.
+ reload_invalidated = false;
GD_MONO_SCOPE_THREAD_ATTACH;
@@ -3544,6 +3545,7 @@ void CSharpScript::_update_name() {
void CSharpScript::_clear() {
tool = false;
valid = false;
+ reload_invalidated = true;
base = nullptr;
native = nullptr;
diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h
index 221bba3af9..2be588cac4 100644
--- a/modules/mono/csharp_script.h
+++ b/modules/mono/csharp_script.h
@@ -101,6 +101,7 @@ private:
bool tool = false;
bool valid = false;
+ bool reload_invalidated = false;
bool builtin;