Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C#: Check if .NET runtime has been finalized in the instance binding reference callback #77362

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions modules/mono/csharp_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,15 @@ void CSharpLanguage::_instance_binding_free_callback(void *, void *, void *p_bin
GDExtensionBool CSharpLanguage::_instance_binding_reference_callback(void *p_token, void *p_binding, GDExtensionBool p_reference) {
CRASH_COND(!p_binding);

if (GDMono::get_singleton() == nullptr) {
#ifdef DEBUG_ENABLED
CSharpLanguage *csharp_lang = CSharpLanguage::get_singleton();
CRASH_COND(csharp_lang && !csharp_lang->script_bindings.is_empty());
#endif
// Mono runtime finalized, all the gchandle bindings were already released
return true;
}

CSharpScriptBinding &script_binding = ((RBMap<Object *, CSharpScriptBinding>::Element *)p_binding)->get();

RefCounted *rc_owner = Object::cast_to<RefCounted>(script_binding.owner);
Expand Down