mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
[.NET] Skip serializing delegates with a disposed target
When reloading assemblies, we serialize the managed delegates so we can recreate the callables later. If the delegate's target is a GodotObject that has already been disposed, we can't serialize the delegate. Before this change, trying to serialize one of these delegates throws an exception and prevents releasing its strong GCHandle, so the assembly can't be unloaded. With this change, we don't serialize the delegates and release them anyway. This means some delegates may get lost on reloading assemblies, but if their target was already freed it's probably fine.
This commit is contained in:
parent
36d90c73a8
commit
2550cdc0c4
2 changed files with 14 additions and 2 deletions
|
@ -690,8 +690,14 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) {
|
|||
|
||||
if (success) {
|
||||
ManagedCallable::instances_pending_reload.insert(managed_callable, serialized_data);
|
||||
} else if (OS::get_singleton()->is_stdout_verbose()) {
|
||||
OS::get_singleton()->print("Failed to serialize delegate\n");
|
||||
} else {
|
||||
if (OS::get_singleton()->is_stdout_verbose()) {
|
||||
OS::get_singleton()->print("Failed to serialize delegate.\n");
|
||||
}
|
||||
|
||||
// We failed to serialize the delegate but we still have to release it;
|
||||
// otherwise, we won't be able to unload the assembly.
|
||||
managed_callable->release_delegate_handle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue