summaryrefslogtreecommitdiffstats
path: root/modules/mono/csharp_script.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/mono/csharp_script.cpp')
-rw-r--r--modules/mono/csharp_script.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index ef24dc35ca..33fef2d58c 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -697,19 +697,25 @@ struct CSharpScriptDepSort {
// Shouldn't happen but just in case...
return false;
}
- const Script *I = B->get_base_script().ptr();
+ const CSharpScript *I = get_base_script(B.ptr()).ptr();
while (I) {
if (I == A.ptr()) {
// A is a base of B
return true;
}
- I = I->get_base_script().ptr();
+ I = get_base_script(I).ptr();
}
// A isn't a base of B
return false;
}
+
+ // Special fix for constructed generic types.
+ Ref<CSharpScript> get_base_script(const CSharpScript *p_script) const {
+ Ref<CSharpScript> base_script = p_script->base_script;
+ return base_script.is_valid() && !base_script->class_name.is_empty() ? base_script : nullptr;
+ }
};
void CSharpLanguage::reload_all_scripts() {
@@ -2897,8 +2903,11 @@ Ref<Resource> ResourceFormatLoaderCSharpScript::load(const String &p_path, const
ERR_FAIL_COND_V_MSG(err != OK, Ref<Resource>(), "Cannot load C# script file '" + p_path + "'.");
#endif
- scr->set_path(p_original_path);
+ // Only one instance of a C# script is allowed to exist.
+ ERR_FAIL_COND_V_MSG(!scr->get_path().is_empty() && scr->get_path() != p_original_path, Ref<Resource>(),
+ "The C# script path is different from the path it was registered in the C# dictionary.");
+ scr->set_path(p_original_path, true);
scr->reload();
if (r_error) {