diff options
author | Raul Santos <raulsntos@gmail.com> | 2024-02-07 06:33:51 +0100 |
---|---|---|
committer | Raul Santos <raulsntos@gmail.com> | 2024-02-07 06:33:51 +0100 |
commit | 8ce4a0cf1554f609b6a12f6bf136440aeb7e34bb (patch) | |
tree | 6fff323eef8b5680e8e2bb0f78f3e73ee830cfd3 /modules/mono/csharp_script.cpp | |
parent | d3352813ea44447bfbf135efdec23acc4d1d3f89 (diff) | |
download | redot-engine-8ce4a0cf1554f609b6a12f6bf136440aeb7e34bb.tar.gz |
C#: Fix crash when reloading scripts
The crash cond was accidentally moved to the `reload_scripts` method when it was only meant to be in the `reload_tool_script` method. Same about restarting the HotReloadAssemblyWatcher timer.
Also removed the loop that checks if the script array contains a C# script because if we're in CSharpLanguage we can assume that at least one of them is.
Diffstat (limited to 'modules/mono/csharp_script.cpp')
-rw-r--r-- | modules/mono/csharp_script.cpp | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index a84febb226..18724ff6e1 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -727,20 +727,15 @@ void CSharpLanguage::reload_all_scripts() { } void CSharpLanguage::reload_scripts(const Array &p_scripts, bool p_soft_reload) { - CRASH_COND(!Engine::get_singleton()->is_editor_hint()); - - bool has_csharp_script = false; - for (int i = 0; i < p_scripts.size(); ++i) { - Ref<CSharpScript> cs_script = p_scripts[i]; - if (cs_script.is_valid()) { - has_csharp_script = true; - break; - } +#ifdef GD_MONO_HOT_RELOAD + if (is_assembly_reloading_needed()) { + reload_assemblies(p_soft_reload); } +#endif +} - if (!has_csharp_script) { - return; - } +void CSharpLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) { + CRASH_COND(!Engine::get_singleton()->is_editor_hint()); #ifdef TOOLS_ENABLED get_godotsharp_editor()->get_node(NodePath("HotReloadAssemblyWatcher"))->call("RestartTimer"); @@ -753,12 +748,6 @@ void CSharpLanguage::reload_scripts(const Array &p_scripts, bool p_soft_reload) #endif } -void CSharpLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) { - Array scripts; - scripts.push_back(p_script); - reload_scripts(scripts, p_soft_reload); -} - #ifdef GD_MONO_HOT_RELOAD bool CSharpLanguage::is_assembly_reloading_needed() { ERR_FAIL_NULL_V(gdmono, false); |