Cleanup - Use RemoveAllChildren() over DisposeAllChildren() (#39848)

* Content - change the (should-be-obsolete) DisposeAllChildren into the more robust RemoveAllChildren.

* Remove duplicate calls.

---------

Co-authored-by: ElectroJr <leonsfriedrich@gmail.com>
This commit is contained in:
LordCarve
2025-09-23 05:40:48 +02:00
committed by GitHub
parent fd40888b0e
commit a3ddba6f42
35 changed files with 49 additions and 52 deletions

View File

@@ -25,7 +25,7 @@ namespace Content.Client.Access.UI
public void SetAccessLevels(IPrototypeManager protoManager, List<ProtoId<AccessLevelPrototype>> accessLevels) public void SetAccessLevels(IPrototypeManager protoManager, List<ProtoId<AccessLevelPrototype>> accessLevels)
{ {
_accessButtons.Clear(); _accessButtons.Clear();
AccessLevelGrid.DisposeAllChildren(); AccessLevelGrid.RemoveAllChildren();
foreach (var access in accessLevels) foreach (var access in accessLevels)
{ {

View File

@@ -41,7 +41,7 @@ namespace Content.Client.Access.UI
public void SetAllowedIcons(string currentJobIconId) public void SetAllowedIcons(string currentJobIconId)
{ {
IconGrid.DisposeAllChildren(); IconGrid.RemoveAllChildren();
var jobIconButtonGroup = new ButtonGroup(); var jobIconButtonGroup = new ButtonGroup();
var i = 0; var i = 0;

View File

@@ -99,8 +99,8 @@ public sealed partial class GroupedAccessLevelChecklist : BoxContainer
private bool TryRebuildAccessGroupControls() private bool TryRebuildAccessGroupControls()
{ {
AccessGroupList.DisposeAllChildren(); AccessGroupList.RemoveAllChildren();
AccessLevelChecklist.DisposeAllChildren(); AccessLevelChecklist.RemoveAllChildren();
// No access level prototypes were assigned to any of the access level groups. // No access level prototypes were assigned to any of the access level groups.
// Either the turret controller has no assigned access levels or their names were invalid. // Either the turret controller has no assigned access levels or their names were invalid.
@@ -165,7 +165,7 @@ public sealed partial class GroupedAccessLevelChecklist : BoxContainer
/// </summary> /// </summary>
public void RebuildAccessLevelsControls() public void RebuildAccessLevelsControls()
{ {
AccessLevelChecklist.DisposeAllChildren(); AccessLevelChecklist.RemoveAllChildren();
_accessLevelEntries.Clear(); _accessLevelEntries.Clear();
// No access level prototypes were assigned to any of the access level groups // No access level prototypes were assigned to any of the access level groups

View File

@@ -67,7 +67,7 @@ namespace Content.Client.Administration.UI.ManageSolutions
/// </summary> /// </summary>
public void UpdateReagents() public void UpdateReagents()
{ {
ReagentList.DisposeAllChildren(); ReagentList.RemoveAllChildren();
if (_selectedSolution == null || _solutions == null) if (_selectedSolution == null || _solutions == null)
return; return;
@@ -92,7 +92,7 @@ namespace Content.Client.Administration.UI.ManageSolutions
/// <param name="solution">The selected solution.</param> /// <param name="solution">The selected solution.</param>
private void UpdateVolumeBox(Solution solution) private void UpdateVolumeBox(Solution solution)
{ {
VolumeBox.DisposeAllChildren(); VolumeBox.RemoveAllChildren();
var volumeLabel = new Label(); var volumeLabel = new Label();
volumeLabel.HorizontalExpand = true; volumeLabel.HorizontalExpand = true;
@@ -131,7 +131,7 @@ namespace Content.Client.Administration.UI.ManageSolutions
/// <param name="solution">The selected solution.</param> /// <param name="solution">The selected solution.</param>
private void UpdateThermalBox(Solution solution) private void UpdateThermalBox(Solution solution)
{ {
ThermalBox.DisposeAllChildren(); ThermalBox.RemoveAllChildren();
var heatCap = solution.GetHeatCapacity(null); var heatCap = solution.GetHeatCapacity(null);
var specificHeatLabel = new Label(); var specificHeatLabel = new Label();
specificHeatLabel.HorizontalExpand = true; specificHeatLabel.HorizontalExpand = true;

View File

@@ -206,7 +206,7 @@ namespace Content.Client.Cargo.UI
if (!_orderConsoleQuery.TryComp(_owner, out var orderConsole)) if (!_orderConsoleQuery.TryComp(_owner, out var orderConsole))
return; return;
Requests.DisposeAllChildren(); Requests.RemoveAllChildren();
foreach (var order in orders) foreach (var order in orders)
{ {

View File

@@ -30,7 +30,7 @@ namespace Content.Client.Cargo.UI
public void SetOrders(SpriteSystem sprites, IPrototypeManager protoManager, List<CargoOrderData> orders) public void SetOrders(SpriteSystem sprites, IPrototypeManager protoManager, List<CargoOrderData> orders)
{ {
Orders.DisposeAllChildren(); Orders.RemoveAllChildren();
foreach (var order in orders) foreach (var order in orders)
{ {

View File

@@ -1,4 +1,4 @@
using Content.Client.CrewManifest.UI; using Content.Client.CrewManifest.UI;
using Content.Shared.CrewManifest; using Content.Shared.CrewManifest;
using Robust.Client.AutoGenerated; using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
@@ -21,7 +21,6 @@ public sealed partial class CrewManifestUiFragment : BoxContainer
public void UpdateState(string stationName, CrewManifestEntries? entries) public void UpdateState(string stationName, CrewManifestEntries? entries)
{ {
CrewManifestListing.DisposeAllChildren();
CrewManifestListing.RemoveAllChildren(); CrewManifestListing.RemoveAllChildren();
StationNameContainer.Visible = entries != null; StationNameContainer.Visible = entries != null;

View File

@@ -55,7 +55,7 @@ namespace Content.Client.Changelog
// Changelog is not kept in memory so load it again. // Changelog is not kept in memory so load it again.
var changelogs = await _changelog.LoadChangelog(); var changelogs = await _changelog.LoadChangelog();
Tabs.DisposeAllChildren(); Tabs.RemoveAllChildren();
var i = 0; var i = 0;
foreach (var changelog in changelogs) foreach (var changelog in changelogs)

View File

@@ -95,7 +95,7 @@ namespace Content.Client.ContextMenu.UI
/// </summary> /// </summary>
public void Close() public void Close()
{ {
RootMenu.MenuBody.DisposeAllChildren(); RootMenu.MenuBody.RemoveAllChildren();
CancelOpen?.Cancel(); CancelOpen?.Cancel();
CancelClose?.Cancel(); CancelClose?.Cancel();
OnContextClosed?.Invoke(); OnContextClosed?.Invoke();

View File

@@ -293,7 +293,7 @@ namespace Content.Client.ContextMenu.UI
var element = new EntityMenuElement(entity); var element = new EntityMenuElement(entity);
element.SubMenu = new ContextMenuPopup(_context, element); element.SubMenu = new ContextMenuPopup(_context, element);
element.SubMenu.OnPopupOpen += () => _verb.OpenVerbMenu(entity, popup: element.SubMenu); element.SubMenu.OnPopupOpen += () => _verb.OpenVerbMenu(entity, popup: element.SubMenu);
element.SubMenu.OnPopupHide += element.SubMenu.MenuBody.DisposeAllChildren; element.SubMenu.OnPopupHide += element.SubMenu.MenuBody.RemoveAllChildren;
_context.AddElement(menu, element); _context.AddElement(menu, element);
Elements.TryAdd(entity, element); Elements.TryAdd(entity, element);
} }

View File

@@ -53,7 +53,7 @@ namespace Content.Client.Crayon.UI
private void RefreshList() private void RefreshList()
{ {
// Clear // Clear
Grids.DisposeAllChildren(); Grids.RemoveAllChildren();
if (_decals == null || _allDecals == null) if (_decals == null || _allDecals == null)
return; return;

View File

@@ -18,7 +18,6 @@ public sealed partial class CrewManifestUi : DefaultWindow
public void Populate(string name, CrewManifestEntries? entries) public void Populate(string name, CrewManifestEntries? entries)
{ {
CrewManifestListing.DisposeAllChildren();
CrewManifestListing.RemoveAllChildren(); CrewManifestListing.RemoveAllChildren();
StationNameContainer.Visible = entries != null; StationNameContainer.Visible = entries != null;

View File

@@ -72,7 +72,7 @@ public sealed partial class GatewayWindow : FancyWindow,
_isUnlockPending = _nextUnlock >= _timing.CurTime; _isUnlockPending = _nextUnlock >= _timing.CurTime;
_isCooldownPending = _nextReady >= _timing.CurTime; _isCooldownPending = _nextReady >= _timing.CurTime;
Container.DisposeAllChildren(); Container.RemoveAllChildren();
if (_destinations.Count == 0) if (_destinations.Count == 0)
{ {

View File

@@ -116,7 +116,7 @@ namespace Content.Client.HealthAnalyzer.UI
AlertsContainer.Visible = showAlerts; AlertsContainer.Visible = showAlerts;
if (showAlerts) if (showAlerts)
AlertsContainer.DisposeAllChildren(); AlertsContainer.RemoveAllChildren();
if (msg.Unrevivable == true) if (msg.Unrevivable == true)
AlertsContainer.AddChild(new RichTextLabel AlertsContainer.AddChild(new RichTextLabel

View File

@@ -404,7 +404,7 @@ public sealed partial class MarkingPicker : Control
var stateNames = GetMarkingStateNames(prototype); var stateNames = GetMarkingStateNames(prototype);
_currentMarkingColors.Clear(); _currentMarkingColors.Clear();
CMarkingColors.DisposeAllChildren(); CMarkingColors.RemoveAllChildren();
List<ColorSelectorSliders> colorSliders = new(); List<ColorSelectorSliders> colorSliders = new();
for (int i = 0; i < prototype.Sprites.Count; i++) for (int i = 0; i < prototype.Sprites.Count; i++)
{ {

View File

@@ -216,7 +216,6 @@ public sealed partial class SingleMarkingPicker : BoxContainer
var marking = _markings[Slot]; var marking = _markings[Slot];
ColorSelectorContainer.DisposeAllChildren();
ColorSelectorContainer.RemoveAllChildren(); ColorSelectorContainer.RemoveAllChildren();
if (marking.MarkingColors.Count != proto.Sprites.Count) if (marking.MarkingColors.Count != proto.Sprites.Count)

View File

@@ -72,7 +72,7 @@ namespace Content.Client.Lobby.UI
public void ReloadCharacterPickers() public void ReloadCharacterPickers()
{ {
_createNewCharacterButton.Orphan(); _createNewCharacterButton.Orphan();
Characters.DisposeAllChildren(); Characters.RemoveAllChildren();
var numberOfFullSlots = 0; var numberOfFullSlots = 0;
var characterButtonsGroup = new ButtonGroup(); var characterButtonsGroup = new ButtonGroup();

View File

@@ -491,7 +491,7 @@ namespace Content.Client.Lobby.UI
/// </summary> /// </summary>
public void RefreshTraits() public void RefreshTraits()
{ {
TraitsList.DisposeAllChildren(); TraitsList.RemoveAllChildren();
var traits = _prototypeManager.EnumeratePrototypes<TraitPrototype>().OrderBy(t => Loc.GetString(t.Name)).ToList(); var traits = _prototypeManager.EnumeratePrototypes<TraitPrototype>().OrderBy(t => Loc.GetString(t.Name)).ToList();
TabContainer.SetTabTitle(3, Loc.GetString("humanoid-profile-editor-traits-tab")); TabContainer.SetTabTitle(3, Loc.GetString("humanoid-profile-editor-traits-tab"));
@@ -632,7 +632,7 @@ namespace Content.Client.Lobby.UI
public void RefreshAntags() public void RefreshAntags()
{ {
AntagList.DisposeAllChildren(); AntagList.RemoveAllChildren();
var items = new[] var items = new[]
{ {
("humanoid-profile-editor-antag-preference-yes-button", 0), ("humanoid-profile-editor-antag-preference-yes-button", 0),
@@ -826,7 +826,7 @@ namespace Content.Client.Lobby.UI
/// </summary> /// </summary>
public void RefreshJobs() public void RefreshJobs()
{ {
JobList.DisposeAllChildren(); JobList.RemoveAllChildren();
_jobCategories.Clear(); _jobCategories.Clear();
_jobPriorities.Clear(); _jobPriorities.Clear();
var firstCategory = true; var firstCategory = true;

View File

@@ -42,7 +42,7 @@ public sealed partial class LoadoutGroupContainer : BoxContainer
{ {
var protoMan = collection.Resolve<IPrototypeManager>(); var protoMan = collection.Resolve<IPrototypeManager>();
var loadoutSystem = collection.Resolve<IEntityManager>().System<LoadoutSystem>(); var loadoutSystem = collection.Resolve<IEntityManager>().System<LoadoutSystem>();
RestrictionsContainer.DisposeAllChildren(); RestrictionsContainer.RemoveAllChildren();
if (_groupProto.MinLimit > 0) if (_groupProto.MinLimit > 0)
{ {
@@ -71,7 +71,7 @@ public sealed partial class LoadoutGroupContainer : BoxContainer
}); });
} }
LoadoutsContainer.DisposeAllChildren(); LoadoutsContainer.RemoveAllChildren();
// Get all loadout prototypes for this group. // Get all loadout prototypes for this group.
var validProtos = _groupProto.Loadouts.Select(id => protoMan.Index(id)); var validProtos = _groupProto.Loadouts.Select(id => protoMan.Index(id));

View File

@@ -43,7 +43,7 @@ public sealed partial class LobbyCharacterPreviewPanel : Control
_previewDummy = uid; _previewDummy = uid;
ViewBox.DisposeAllChildren(); ViewBox.RemoveAllChildren();
var spriteView = new SpriteView var spriteView = new SpriteView
{ {
OverrideDirection = Direction.South, OverrideDirection = Direction.South,

View File

@@ -1,4 +1,4 @@
using System.Numerics; using System.Numerics;
using Robust.Client.AutoGenerated; using Robust.Client.AutoGenerated;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
@@ -37,7 +37,7 @@ public sealed partial class MappingPrototypeList : Control
{ {
_prototypes.Clear(); _prototypes.Clear();
PrototypeList.DisposeAllChildren(); PrototypeList.RemoveAllChildren();
_prototypes.AddRange(prototypes); _prototypes.AddRange(prototypes);
@@ -99,7 +99,7 @@ public sealed partial class MappingPrototypeList : Control
public void Search(List<MappingPrototype> prototypes) public void Search(List<MappingPrototype> prototypes)
{ {
_search.Clear(); _search.Clear();
SearchList.DisposeAllChildren(); SearchList.RemoveAllChildren();
_lastIndices = (0, -1); _lastIndices = (0, -1);
_search.AddRange(prototypes); _search.AddRange(prototypes);

View File

@@ -861,7 +861,7 @@ public sealed class MappingState : GameplayStateBase
} }
else else
{ {
button.ChildrenPrototypes.DisposeAllChildren(); button.ChildrenPrototypes.RemoveAllChildren();
button.CollapseButton.Label.Text = "▶"; button.CollapseButton.Label.Text = "▶";
} }
} }

View File

@@ -53,8 +53,8 @@ public sealed partial class PowerMonitoringWindow
// Selection action // Selection action
windowEntry.Button.OnButtonUp += args => windowEntry.Button.OnButtonUp += args =>
{ {
windowEntry.SourcesContainer.DisposeAllChildren(); windowEntry.SourcesContainer.RemoveAllChildren();
windowEntry.LoadsContainer.DisposeAllChildren(); windowEntry.LoadsContainer.RemoveAllChildren();
ButtonAction(windowEntry, masterContainer); ButtonAction(windowEntry, masterContainer);
}; };
} }

View File

@@ -70,7 +70,7 @@ public sealed partial class OfferingWindow : FancyWindow,
public void ClearOptions() public void ClearOptions()
{ {
Container.DisposeAllChildren(); Container.RemoveAllChildren();
} }
protected override void FrameUpdate(FrameEventArgs args) protected override void FrameUpdate(FrameEventArgs args)

View File

@@ -67,8 +67,8 @@ public sealed partial class DockingScreen : BoxContainer
{ {
DockingControl.BuildDocks(shuttle); DockingControl.BuildDocks(shuttle);
var currentDock = DockingControl.ViewedDock; var currentDock = DockingControl.ViewedDock;
// DockedWith.DisposeAllChildren(); // DockedWith.RemoveAllChildren();
DockPorts.DisposeAllChildren(); DockPorts.RemoveAllChildren();
_ourDockButtons.Clear(); _ourDockButtons.Clear();
if (shuttle == null) if (shuttle == null)

View File

@@ -59,7 +59,7 @@ public sealed partial class EmergencyConsoleWindow : FancyWindow,
// TODO: Loc and cvar for this. // TODO: Loc and cvar for this.
_earlyLaunchTime = scc.EarlyLaunchTime; _earlyLaunchTime = scc.EarlyLaunchTime;
AuthorizationsContainer.DisposeAllChildren(); AuthorizationsContainer.RemoveAllChildren();
var remainingAuths = scc.AuthorizationsRequired - scc.Authorizations.Count; var remainingAuths = scc.AuthorizationsRequired - scc.Authorizations.Count;
AuthorizationCount.Text = Loc.GetString("emergency-shuttle-ui-remaining", ("remaining", remainingAuths)); AuthorizationCount.Text = Loc.GetString("emergency-shuttle-ui-remaining", ("remaining", remainingAuths));

View File

@@ -237,7 +237,7 @@ public sealed partial class MapScreen : BoxContainer
private void ClearMapObjects() private void ClearMapObjects()
{ {
_mapObjectControls.Clear(); _mapObjectControls.Clear();
HyperspaceDestinations.DisposeAllChildren(); HyperspaceDestinations.RemoveAllChildren();
_pendingMapObjects.Clear(); _pendingMapObjects.Clear();
_mapObjects.Clear(); _mapObjects.Clear();
_mapHeadings.Clear(); _mapHeadings.Clear();

View File

@@ -25,9 +25,9 @@ namespace Content.Client.Strip
public void ClearButtons() public void ClearButtons()
{ {
InventoryContainer.DisposeAllChildren(); InventoryContainer.RemoveAllChildren();
HandsContainer.DisposeAllChildren(); HandsContainer.RemoveAllChildren();
SnareContainer.DisposeAllChildren(); SnareContainer.RemoveAllChildren();
} }
protected override void FrameUpdate(FrameEventArgs args) protected override void FrameUpdate(FrameEventArgs args)

View File

@@ -29,7 +29,7 @@ public sealed partial class ThiefBackpackMenu : FancyWindow
public void UpdateState(ThiefBackpackBoundUserInterfaceState state) public void UpdateState(ThiefBackpackBoundUserInterfaceState state)
{ {
SetsGrid.DisposeAllChildren(); SetsGrid.RemoveAllChildren();
var selectedNumber = 0; var selectedNumber = 0;
foreach (var (set, info) in state.Sets) foreach (var (set, info) in state.Sets)
{ {

View File

@@ -1,4 +1,4 @@
using System.Numerics; using System.Numerics;
using Robust.Client.AutoGenerated; using Robust.Client.AutoGenerated;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
@@ -19,7 +19,7 @@ namespace Content.Client.UserInterface.Controls
public void Clear() public void Clear()
{ {
DisposeAllChildren(); RemoveAllChildren();
} }
public void AddEntry(float amount, Color color, string? tooltip = null) public void AddEntry(float amount, Color color, string? tooltip = null)

View File

@@ -17,7 +17,7 @@ namespace Content.Client.UserInterface
public void UpdateValues(List<string> headers, List<string[]> values) public void UpdateValues(List<string> headers, List<string[]> values)
{ {
Values.DisposeAllChildren(); Values.RemoveAllChildren();
Values.Columns = headers.Count; Values.Columns = headers.Count;
for (var i = 0; i < headers.Count; i++) for (var i = 0; i < headers.Count; i++)

View File

@@ -45,7 +45,7 @@ namespace Content.Client.UserInterface.Systems.Ghost.Controls
public void Populate() public void Populate()
{ {
ButtonContainer.DisposeAllChildren(); ButtonContainer.RemoveAllChildren();
AddButtons(); AddButtons();
} }

View File

@@ -26,7 +26,7 @@ namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles
public void ClearEntries() public void ClearEntries()
{ {
NoRolesMessage.Visible = true; NoRolesMessage.Visible = true;
EntryContainer.DisposeAllChildren(); EntryContainer.RemoveAllChildren();
_collapsibleBoxes.Clear(); _collapsibleBoxes.Clear();
} }

View File

@@ -1,4 +1,4 @@
using System.Linq; using System.Linq;
using Content.Client.UserInterface.Systems.Inventory.Controls; using Content.Client.UserInterface.Systems.Inventory.Controls;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
@@ -74,7 +74,7 @@ public sealed class HandsContainer : ItemSlotUIContainer<HandButton>
public void Clear() public void Clear()
{ {
ClearButtons(); ClearButtons();
_grid.DisposeAllChildren(); _grid.RemoveAllChildren();
} }
public IEnumerable<HandButton> GetButtons() public IEnumerable<HandButton> GetButtons()

View File

@@ -109,7 +109,7 @@ namespace Content.Client.Verbs.UI
Close(); Close();
var menu = popup ?? _context.RootMenu; var menu = popup ?? _context.RootMenu;
menu.MenuBody.DisposeAllChildren(); menu.MenuBody.RemoveAllChildren();
CurrentTarget = target; CurrentTarget = target;
CurrentVerbs = _verbSystem.GetVerbs(target, user, Verb.VerbTypes, out ExtraCategories, force); CurrentVerbs = _verbSystem.GetVerbs(target, user, Verb.VerbTypes, out ExtraCategories, force);
@@ -207,7 +207,7 @@ namespace Content.Client.Verbs.UI
/// </summary> /// </summary>
public void AddServerVerbs(List<Verb>? verbs, ContextMenuPopup popup) public void AddServerVerbs(List<Verb>? verbs, ContextMenuPopup popup)
{ {
popup.MenuBody.DisposeAllChildren(); popup.MenuBody.RemoveAllChildren();
// Verbs may be null if the server does not think we can see the target entity. This **should** not happen. // Verbs may be null if the server does not think we can see the target entity. This **should** not happen.
if (verbs == null) if (verbs == null)