From 76ca202f38cd1962511e5a20739e5bcb206924d1 Mon Sep 17 00:00:00 2001 From: Soreepeong Date: Thu, 14 Mar 2024 12:54:12 +0900 Subject: [PATCH] Comments on RemoveNonDalamudInvocations --- .../ImGuiNotification/Internal/ActiveNotification.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Dalamud/Interface/ImGuiNotification/Internal/ActiveNotification.cs b/Dalamud/Interface/ImGuiNotification/Internal/ActiveNotification.cs index c54a9c6fa..019d9e281 100644 --- a/Dalamud/Interface/ImGuiNotification/Internal/ActiveNotification.cs +++ b/Dalamud/Interface/ImGuiNotification/Internal/ActiveNotification.cs @@ -252,6 +252,14 @@ internal sealed partial class ActiveNotification : IActiveNotification } /// Removes non-Dalamud invocation targets from events. + /// + /// This is done to prevent references of plugins being unloaded from outliving the plugin itself. + /// Anything that can contain plugin-provided types and functions count, which effectively means that events and + /// interface/object-typed fields need to be scrubbed. + /// As a notification can be marked as non-user-dismissable, in which case after removing event handlers there will + /// be no way to remove the notification, we force the notification to become user-dismissable, and reset the expiry + /// to the default duration on unload. + /// internal void RemoveNonDalamudInvocations() { var dalamudContext = AssemblyLoadContext.GetLoadContext(typeof(NotificationManager).Assembly);