diff --git a/Dalamud/Game/Addon/Lifecycle/AddonLifecycle.cs b/Dalamud/Game/Addon/Lifecycle/AddonLifecycle.cs
index c7bbef002..70e7b7f9d 100644
--- a/Dalamud/Game/Addon/Lifecycle/AddonLifecycle.cs
+++ b/Dalamud/Game/Addon/Lifecycle/AddonLifecycle.cs
@@ -134,6 +134,9 @@ internal unsafe class AddonLifecycle : IInternalDisposableService
/// The listener to unregister.
internal void UnregisterListener(AddonLifecycleEventListener listener)
{
+ // Set removed state to true immediately, then lazily remove it from the EventListeners list on next Framework Update.
+ listener.Removed = true;
+
this.framework.RunOnTick(() =>
{
this.EventListeners.Remove(listener);
@@ -168,6 +171,10 @@ internal unsafe class AddonLifecycle : IInternalDisposableService
if (listener.EventType != eventType)
continue;
+ // If the listener is pending removal, and is waiting until the next Framework Update, don't invoke listener.
+ if (listener.Removed)
+ continue;
+
// Match on string.empty for listeners that want events for all addons.
if (!string.IsNullOrWhiteSpace(listener.AddonName) && !args.IsAddon(listener.AddonName))
continue;
diff --git a/Dalamud/Game/Addon/Lifecycle/AddonLifecycleEventListener.cs b/Dalamud/Game/Addon/Lifecycle/AddonLifecycleEventListener.cs
index 6464a1edd..9d411cdbc 100644
--- a/Dalamud/Game/Addon/Lifecycle/AddonLifecycleEventListener.cs
+++ b/Dalamud/Game/Addon/Lifecycle/AddonLifecycleEventListener.cs
@@ -26,6 +26,11 @@ internal class AddonLifecycleEventListener
///
public string AddonName { get; init; }
+ ///
+ /// Gets or sets a value indicating whether this event has been unregistered.
+ ///
+ public bool Removed { get; set; }
+
///
/// Gets the event type this listener is looking for.
///
diff --git a/Dalamud/Game/Gui/Dtr/DtrBarEntry.cs b/Dalamud/Game/Gui/Dtr/DtrBarEntry.cs
index b549afb8b..1cc51cfe4 100644
--- a/Dalamud/Game/Gui/Dtr/DtrBarEntry.cs
+++ b/Dalamud/Game/Gui/Dtr/DtrBarEntry.cs
@@ -90,7 +90,7 @@ public sealed unsafe class DtrBarEntry : IDisposable, IDtrBarEntry
private readonly DalamudConfiguration configuration;
private bool shownBacking = true;
- private SeString? textBacking = null;
+ private SeString? textBacking;
///
/// Initializes a new instance of the class.
@@ -153,18 +153,18 @@ public sealed unsafe class DtrBarEntry : IDisposable, IDtrBarEntry
///
/// Gets a value indicating whether this entry should be removed.
///
- internal bool ShouldBeRemoved { get; private set; } = false;
+ internal bool ShouldBeRemoved { get; private set; }
///
/// Gets or sets a value indicating whether this entry is dirty.
///
- internal bool Dirty { get; set; } = false;
+ internal bool Dirty { get; set; }
///
/// Gets or sets a value indicating whether this entry has just been added.
///
- internal bool Added { get; set; } = false;
-
+ internal bool Added { get; set; }
+
///
public bool TriggerClickAction()
{