From 659b89c61546cf4f1cc05d9a4310ee35f0a24599 Mon Sep 17 00:00:00 2001 From: 31 <31eee384@gmail.com> Date: Wed, 7 Apr 2021 00:56:38 -0500 Subject: [PATCH] Fix 'script_class' null access when reloading a deleted C# script (cherry picked from commit 6fd2edddc003729755977688790fe9873cbd72f3) --- modules/mono/csharp_script.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 10cb6baaf11..9ad9111632e 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -783,6 +783,12 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { for (List>::Element *E = scripts.front(); E; E = E->next()) { Ref &script = E->get(); + // If someone removes a script from a node, deletes the script, builds, adds a script to the + // same node, then builds again, the script might have no path and also no script_class. In + // that case, we can't (and don't need to) reload it. + if (script->get_path().empty() && !script->script_class) { + continue; + } to_reload.push_back(script);