Merge pull request #101006 from zaevi/fix_csharp_refcounted_dispose
C#: Fix `RefCounted` not disposed correctly in certain case
This commit is contained in:
commit
f8b2f1bc82
1 changed files with 5 additions and 0 deletions
|
|
@ -203,6 +203,11 @@ void godotsharp_internal_refcounted_disposed(Object *p_ptr, GCHandleIntPtr p_gch
|
|||
CSharpScriptBinding &script_binding = ((RBMap<Object *, CSharpScriptBinding>::Element *)data)->get();
|
||||
if (script_binding.inited) {
|
||||
if (!script_binding.gchandle.is_released()) {
|
||||
if (rc->get_reference_count() == 1 && script_binding.gchandle.is_weak()) {
|
||||
// The GCHandle is just swapped, so get the swapped handle to release
|
||||
// See: CSharpLanguage::_instance_binding_reference_callback(void *p_token, void *p_binding, GDExtensionBool p_reference)
|
||||
p_gchandle_to_free = script_binding.gchandle.get_intptr();
|
||||
}
|
||||
CSharpLanguage::release_binding_gchandle_thread_safe(p_gchandle_to_free, script_binding);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue