summaryrefslogtreecommitdiff
path: root/modules/mono/csharp_script.cpp
diff options
context:
space:
mode:
authorRaul Santos <raulsntos@gmail.com>2021-12-06 19:45:59 +0100
committerRaul Santos <raulsntos@gmail.com>2021-12-06 19:45:59 +0100
commit4a339dc8fdd6429b50cbf0861dc011db23accc63 (patch)
tree1ec4686012d8d13627ce25df86ecf5d26edf2821 /modules/mono/csharp_script.cpp
parent3ae8eda1ed30b6c32f6fc1141118c5a062161a96 (diff)
C# script reload fixed
Co-authored-by: Michael Bickel <mib@developium.net> Co-authored-by: Germanrc <german_1995a@hotmail.com>
Diffstat (limited to 'modules/mono/csharp_script.cpp')
-rw-r--r--modules/mono/csharp_script.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 0ceb45d425..e6eb9db112 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -3009,6 +3009,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);
@@ -3365,13 +3366,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;
@@ -3558,6 +3559,7 @@ void CSharpScript::_update_name() {
void CSharpScript::_clear() {
tool = false;
valid = false;
+ reload_invalidated = true;
base = nullptr;
native = nullptr;