Skip to content

Commit 870b32d

Browse files
committed
fix: Ban/Mute game client DC
AscensionGameDev#2787
1 parent 38cd772 commit 870b32d

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

Intersect.Client.Core/Interface/Game/Admin/BanMuteBox.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Intersect.Client.Interface.Game.Admin;
88
public partial class BanMuteBox : WindowControl
99
{
1010
private readonly TextBox _textboxReason;
11-
private readonly ComboBox? _comboboxDuration;
11+
private readonly ComboBox _comboboxDuration;
1212
private readonly LabeledCheckBox _checkboxIP;
1313

1414
private static readonly List<(string Label, int Days)> _durationOptions = new()
@@ -24,7 +24,7 @@ public partial class BanMuteBox : WindowControl
2424
(Strings.BanMute.TwoMonths, 60),
2525
(Strings.BanMute.SixMonths, 180),
2626
(Strings.BanMute.OneYear, 365),
27-
(Strings.BanMute.Forever, int.MaxValue),
27+
(Strings.BanMute.Forever, 999999),
2828
};
2929

3030
public BanMuteBox(string title, string prompt, EventHandler okayHandler) : base(
@@ -79,14 +79,14 @@ public BanMuteBox(string title, string prompt, EventHandler okayHandler) : base(
7979
buttonOkay.Clicked += (s, e) =>
8080
{
8181
okayHandler?.Invoke(this, EventArgs.Empty);
82-
Close();
82+
DelayedDelete();
8383
};
8484

8585
var buttonCancel = new Button(this, "ButtonCancel")
8686
{
8787
Text = Strings.BanMute.Cancel,
8888
};
89-
buttonCancel.Clicked += (s, e) => Close();
89+
buttonCancel.Clicked += (s, e) => DelayedDelete();
9090

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

Intersect.Client.Framework/Gwen/Control/Canvas.cs

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,21 +262,42 @@ public void AddDelayedDelete(Base control)
262262

263263
private void ProcessDelayedDeletes()
264264
{
265+
List<IDisposable> controlsToDispose;
266+
265267
lock (_disposeQueue)
266268
{
267-
foreach (var control in _disposeQueue)
269+
if (_disposeQueue.Count == 0)
268270
{
271+
return;
272+
}
273+
274+
controlsToDispose = new List<IDisposable>(_disposeQueue);
275+
_disposeQueue.Clear();
276+
269277
#if DEBUG
270-
if (control is Base node)
271-
{
272-
_delayedDeleteStackTraces.Remove(node);
273-
}
278+
// Remove all the stuff from debug tracking in one go
279+
_delayedDeleteStackTraces.Clear();
274280
#endif
281+
}
275282

283+
// Dispose outside the lock
284+
foreach (var control in controlsToDispose)
285+
{
286+
try
287+
{
276288
control.Dispose();
277289
}
278-
279-
_disposeQueue.Clear();
290+
catch (ObjectDisposedException)
291+
{
292+
// Already disposed, ignore
293+
}
294+
catch (Exception ex)
295+
{
296+
ApplicationContext.Context.Value?.Logger.LogError(
297+
ex,
298+
"Error disposing control during ProcessDelayedDeletes"
299+
);
300+
}
280301
}
281302
}
282303

@@ -462,4 +483,4 @@ public bool Input_MouseWheel(int val)
462483
return InputHandler.HoveredControl.InputMouseWheeled(val);
463484
}
464485

465-
}
486+
}

0 commit comments

Comments
 (0)