Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions Intersect.Client.Core/Interface/Game/Admin/BanMuteBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ public BanMuteBox(string title, string prompt, EventHandler okayHandler) : base(
buttonOkay.Clicked += (s, e) =>
{
okayHandler?.Invoke(this, EventArgs.Empty);
Dispose();
DelayedDelete();
};

var buttonCancel = new Button(this, "ButtonCancel")
{
Text = Strings.BanMute.Cancel,
};
buttonCancel.Clicked += (s, e) => Dispose();
buttonCancel.Clicked += (s, e) => DelayedDelete();

LoadJsonUi(UI.InGame, Graphics.Renderer?.GetResolutionString(), true);

Expand Down
35 changes: 28 additions & 7 deletions Intersect.Client.Framework/Gwen/Control/Canvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,21 +262,42 @@ public void AddDelayedDelete(Base control)

private void ProcessDelayedDeletes()
{
List<IDisposable> controlsToDispose;

lock (_disposeQueue)
{
foreach (var control in _disposeQueue)
if (_disposeQueue.Count == 0)
{
return;
}

controlsToDispose = new List<IDisposable>(_disposeQueue);
_disposeQueue.Clear();

#if DEBUG
if (control is Base node)
{
_delayedDeleteStackTraces.Remove(node);
}
// Remove all the stuff from debug tracking in one go
_delayedDeleteStackTraces.Clear();
#endif
}

// Dispose outside the lock
foreach (var control in controlsToDispose)
{
try
{
control.Dispose();
}

_disposeQueue.Clear();
catch (ObjectDisposedException)
{
// Already disposed, ignore
}
catch (Exception ex)
{
ApplicationContext.Context.Value?.Logger.LogError(
ex,
"Error disposing control during ProcessDelayedDeletes"
);
}
}
}

Expand Down
Loading