Skip to content

Commit

Permalink
Merge pull request #19971 from peppy/remove-dispose-updates
Browse files Browse the repository at this point in the history
Update `Remove`/`RemoveRange`/`RemoveAll` calls in line with framework changes
  • Loading branch information
frenzibyte authored Sep 3, 2022
2 parents 7364173 + ff4a051 commit cbc3627
Show file tree
Hide file tree
Showing 53 changed files with 77 additions and 76 deletions.
2 changes: 1 addition & 1 deletion osu.Android.props
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.831.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.825.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.901.0" />
</ItemGroup>
<ItemGroup Label="Transitive Dependencies">
<!-- Realm needs to be directly referenced in all Xamarin projects, as it will not pull in its transitive dependencies otherwise. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected EditablePath(Func<float, double> positionToTime)
public void UpdateFrom(ScrollingHitObjectContainer hitObjectContainer, JuiceStream hitObject)
{
while (path.Vertices.Count < InternalChildren.Count)
RemoveInternal(InternalChildren[^1]);
RemoveInternal(InternalChildren[^1], true);

while (InternalChildren.Count < path.Vertices.Count)
AddInternal(new VertexPiece());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void UpdateNestedObjectsFrom(ScrollingHitObjectContainer hitObjectContain
.Where(h => !(h is TinyDroplet)));

while (nestedHitObjects.Count < InternalChildren.Count)
RemoveInternal(InternalChildren[^1]);
RemoveInternal(InternalChildren[^1], true);

while (InternalChildren.Count < nestedHitObjects.Count)
AddInternal(new FruitOutline());
Expand Down
6 changes: 3 additions & 3 deletions osu.Game.Rulesets.Catch/UI/Catcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ public void OnRevertResult(DrawableCatchHitObject drawableObject, JudgementResul
SetHyperDashState();
}

caughtObjectContainer.RemoveAll(d => d.HitObject == drawableObject.HitObject);
droppedObjectTarget.RemoveAll(d => d.HitObject == drawableObject.HitObject);
caughtObjectContainer.RemoveAll(d => d.HitObject == drawableObject.HitObject, false);
droppedObjectTarget.RemoveAll(d => d.HitObject == drawableObject.HitObject, false);
}

/// <summary>
Expand Down Expand Up @@ -430,7 +430,7 @@ private void removeFromPlate(CaughtObject caughtObject, DroppedObjectAnimation a
{
var droppedObject = getDroppedObject(caughtObject);

caughtObjectContainer.Remove(caughtObject);
caughtObjectContainer.Remove(caughtObject, false);

droppedObjectTarget.Add(droppedObject);

Expand Down
6 changes: 3 additions & 3 deletions osu.Game.Rulesets.Catch/UI/CatcherTrailDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ protected override void RemoveDrawable(CatcherTrailEntry entry, CatcherTrail dra
switch (entry.Animation)
{
case CatcherTrailAnimation.Dashing:
dashTrails.Remove(drawable);
dashTrails.Remove(drawable, false);
break;

case CatcherTrailAnimation.HyperDashing:
hyperDashTrails.Remove(drawable);
hyperDashTrails.Remove(drawable, false);
break;

case CatcherTrailAnimation.HyperDashAfterImage:
hyperDashAfterImages.Remove(drawable);
hyperDashAfterImages.Remove(drawable, false);
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Mania/Mods/ManiaModPlayfieldCover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public virtual void ApplyToDrawableRuleset(DrawableRuleset<ManiaHitObject> drawa
HitObjectContainer hoc = column.HitObjectArea.HitObjectContainer;
Container hocParent = (Container)hoc.Parent;

hocParent.Remove(hoc);
hocParent.Remove(hoc, false);
hocParent.Add(new PlayfieldCoveringWrapper(hoc).With(c =>
{
c.RelativeSizeAxes = Axes.Both;
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyBodyPiece.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private void onIsHittingChanged(ValueChangedEvent<bool> isHitting)
else
{
lightContainer.FadeOut(120)
.OnComplete(d => Column.TopLevelContainer.Remove(d));
.OnComplete(d => Column.TopLevelContainer.Remove(d, false));
}
}

Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Rulesets.Osu.Tests/TestSceneFollowPoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private void removeObjectStep(Func<DrawableOsuHitObject> getFunc)
{
var drawableObject = getFunc.Invoke();

hitObjectContainer.Remove(drawableObject);
hitObjectContainer.Remove(drawableObject, false);
followPointRenderer.RemoveFollowPoints(drawableObject.HitObject);
});
}
Expand All @@ -212,7 +212,7 @@ private void reorderObjectStep(int startIndex, int endIndex)
else
targetTime = getObject(hitObjectContainer.Count - 1).HitObject.StartTime + 1;

hitObjectContainer.Remove(toReorder);
hitObjectContainer.Remove(toReorder, false);
toReorder.HitObject.StartTime = targetTime;
hitObjectContainer.Add(toReorder);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected override void OnFree()
// This is a bit ugly but we don't have the concept of InternalContent so it'll have to do for now. (https://github.com/ppy/osu-framework/issues/1690)
protected override void AddInternal(Drawable drawable) => shakeContainer.Add(drawable);
protected override void ClearInternal(bool disposeChildren = true) => shakeContainer.Clear(disposeChildren);
protected override bool RemoveInternal(Drawable drawable) => shakeContainer.Remove(drawable);
protected override bool RemoveInternal(Drawable drawable, bool disposeImmediately) => shakeContainer.Remove(drawable, disposeImmediately);

protected sealed override double InitialLifetimeOffset => HitObject.TimePreempt;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected void ProxyContent()

isProxied = true;

nonProxiedContent.Remove(Content);
nonProxiedContent.Remove(Content, false);
proxiedContent.Add(Content);
}

Expand All @@ -70,7 +70,7 @@ protected void UnproxyContent()

isProxied = false;

proxiedContent.Remove(Content);
proxiedContent.Remove(Content, false);
nonProxiedContent.Add(Content);
}

Expand Down Expand Up @@ -141,7 +141,7 @@ protected virtual void RecreatePieces()
Size = BaseSize = new Vector2(TaikoHitObject.DEFAULT_SIZE);

if (MainPiece != null)
Content.Remove(MainPiece);
Content.Remove(MainPiece, true);

Content.Add(MainPiece = CreateMainPiece());
}
Expand Down
4 changes: 3 additions & 1 deletion osu.Game.Tests/Editing/Checks/CheckAudioQualityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
using Moq;
using NUnit.Framework;
using osu.Framework.Audio.Track;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Checks;
using osu.Game.Rulesets.Objects;
using osu.Game.Tests.Visual;

namespace osu.Game.Tests.Editing.Checks
{
Expand Down Expand Up @@ -109,7 +111,7 @@ private BeatmapVerifierContext getContext(int? audioBitrate)
/// <param name="audioBitrate">The bitrate of the audio file the beatmap uses.</param>
private Mock<IWorkingBeatmap> getMockWorkingBeatmap(int? audioBitrate)
{
var mockTrack = new Mock<Track>();
var mockTrack = new Mock<OsuTestScene.ClockBackedTestWorkingBeatmap.TrackVirtualManual>(new FramedClock(), "virtual");
mockTrack.SetupGet(t => t.Bitrate).Returns(audioBitrate);

var mockWorkingBeatmap = new Mock<IWorkingBeatmap>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private void createLoader()
=> AddStep("create loader", () =>
{
if (backgroundLoader != null)
Remove(backgroundLoader);
Remove(backgroundLoader, true);

Add(backgroundLoader = new SeasonalBackgroundLoader());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected bool AssertComponentsFromExpectedSource(SkinnableTarget target, ISkin
Add(expectedComponentsAdjustmentContainer);
expectedComponentsAdjustmentContainer.UpdateSubTree();
var expectedInfo = expectedComponentsContainer.CreateSkinnableInfo();
Remove(expectedComponentsAdjustmentContainer);
Remove(expectedComponentsAdjustmentContainer, true);

return almostEqual(actualInfo, expectedInfo);
}
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Tests/Visual/Gameplay/TestSceneSpectatorHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public override void TearDownSteps()
{
base.TearDownSteps();
AddStep("stop watching user", () => spectatorClient.StopWatchingUser(dummy_user_id));
AddStep("remove test spectator client", () => Remove(spectatorClient));
AddStep("remove test spectator client", () => Remove(spectatorClient, false));
}
}
}
4 changes: 2 additions & 2 deletions osu.Game.Tests/Visual/Gameplay/TestSceneStoryboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private void restart()
private void loadStoryboard(IWorkingBeatmap working)
{
if (storyboard != null)
storyboardContainer.Remove(storyboard);
storyboardContainer.Remove(storyboard, true);

var decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = true };
storyboardContainer.Clock = decoupledClock;
Expand All @@ -106,7 +106,7 @@ private void loadStoryboard(IWorkingBeatmap working)
private void loadStoryboardNoVideo()
{
if (storyboard != null)
storyboardContainer.Remove(storyboard);
storyboardContainer.Remove(storyboard, true);

var decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = true };
storyboardContainer.Clock = decoupledClock;
Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Tests/Visual/Menus/TestSceneToolbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ private void load()
[SetUp]
public void SetUp() => Schedule(() =>
{
Remove(nowPlayingOverlay);
Remove(volumeOverlay);
Remove(nowPlayingOverlay, false);
Remove(volumeOverlay, false);

Children = new Drawable[]
{
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Tests/Visual/Navigation/TestSettingsMigration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void TestDisplayStarsMigration()

AddStep("force save config", () => Game.LocalConfig.Save());

AddStep("remove game", () => Remove(Game));
AddStep("remove game", () => Remove(Game, true));

AddStep("create game again", CreateGame);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public TestSceneLeaderboardModSelector()
{
if (selected.Text == mod.Acronym)
{
selectedMods.Remove(selected);
selectedMods.Remove(selected, true);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private void showMetadataForBeatmap(Func<IWorkingBeatmap> getBeatmap)

OsuLogo logo = new OsuLogo { Scale = new Vector2(0.15f) };

Remove(testDifficultyCache);
Remove(testDifficultyCache, false);

Children = new Drawable[]
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ private void addFacadeContainers()

private void removeFacade()
{
trackingContainer.Remove(logoFacade);
trackingContainer.Remove(logoFacade, false);
visualBox.Colour = Color4.White;
moveLogoFacade();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private void createScreen()
{
AddStep("setup screen", () =>
{
Remove(chat);
Remove(chat, false);

Children = new Drawable[]
{
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Tournament/Screens/Drawings/Components/Group.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public bool RemoveTeam(TournamentTeam team)
{
allTeams.RemoveAll(gt => gt.Team == team);

if (teams.RemoveAll(gt => gt.Team == team) > 0)
if (teams.RemoveAll(gt => gt.Team == team, true) > 0)
{
TeamsCount--;
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public void AddTeam(TournamentTeam team)

availableTeams.Add(team);

RemoveAll(c => c is ScrollingTeam);
RemoveAll(c => c is ScrollingTeam, true);
setScrollState(ScrollState.Idle);
}

Expand All @@ -186,7 +186,7 @@ public void AddTeams(IEnumerable<TournamentTeam> teams)
public void ClearTeams()
{
availableTeams.Clear();
RemoveAll(c => c is ScrollingTeam);
RemoveAll(c => c is ScrollingTeam, true);
setScrollState(ScrollState.Idle);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private void removeLine()
if (allLines.Count == 0)
return;

Remove(allLines.First());
Remove(allLines.First(), true);
allLines.Remove(allLines.First());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private void load()
break;

case NotifyCollectionChangedAction.Remove:
args.OldItems.Cast<TModel>().ForEach(i => flow.RemoveAll(d => d.Model == i));
args.OldItems.Cast<TModel>().ForEach(i => flow.RemoveAll(d => d.Model == i, true));
break;
}
};
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Graphics/Backgrounds/Background.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void BlurTo(Vector2 newBlurSigma, double duration = 0, Easing easing = Ea
{
if (bufferedContainer == null && newBlurSigma != Vector2.Zero)
{
RemoveInternal(Sprite);
RemoveInternal(Sprite, false);

AddInternal(bufferedContainer = new BufferedContainer(cachedFrameBuffer: true)
{
Expand Down
7 changes: 5 additions & 2 deletions osu.Game/Graphics/Containers/SectionsContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Drawable ExpandableHeader
if (value == expandableHeader) return;

if (expandableHeader != null)
RemoveInternal(expandableHeader);
RemoveInternal(expandableHeader, false);

expandableHeader = value;

Expand All @@ -55,6 +55,7 @@ public Drawable FixedHeader

fixedHeader?.Expire();
fixedHeader = value;

if (value == null) return;

AddInternal(fixedHeader);
Expand All @@ -70,8 +71,10 @@ public Drawable Footer
if (value == footer) return;

if (footer != null)
scrollContainer.Remove(footer);
scrollContainer.Remove(footer, false);

footer = value;

if (value == null) return;

footer.Anchor |= Anchor.y2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public override void Add(T drawable)
drawable.StateChanged += state => selectionChanged(drawable, state);
}

public override bool Remove(T drawable)
public override bool Remove(T drawable, bool disposeImmediately)
=> throw new NotSupportedException($"Cannot remove drawables from {nameof(SelectionCycleFillFlowContainer<T>)}");

private void setSelected(int? value)
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Graphics/UserInterface/BarGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public IEnumerable<float> Values
}

//I'm using ToList() here because Where() returns an Enumerable which can change it's elements afterwards
RemoveRange(Children.Where((_, index) => index >= value.Count()).ToList());
RemoveRange(Children.Where((_, index) => index >= value.Count()).ToList(), true);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Graphics/UserInterface/TwoLayerButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public override Anchor Origin

X = value.HasFlagFast(Anchor.x2) ? SIZE_RETRACTED.X * shear.X * 0.5f : 0;

Remove(c1);
Remove(c2);
Remove(c1, false);
Remove(c2, false);
c1.Depth = value.HasFlagFast(Anchor.x2) ? 0 : 1;
c2.Depth = value.HasFlagFast(Anchor.x2) ? 1 : 0;
Add(c1);
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Overlays/Chat/ChannelList/ChannelList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void RemoveChannel(Channel channel)
FillFlowContainer<ChannelListItem> flow = getFlowForChannel(channel);

channelMap.Remove(channel);
flow.Remove(item);
flow.Remove(item, true);

updateVisibility();
}
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Overlays/Chat/DrawableChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private void pendingMessageResolved(Message existing, Message updated) => Schedu
{
Trace.Assert(updated.Id.HasValue, "An updated message was returned with no ID.");

ChatLineFlow.Remove(found);
ChatLineFlow.Remove(found, false);
found.Message = updated;
ChatLineFlow.Add(found);
}
Expand Down
Loading

0 comments on commit cbc3627

Please sign in to comment.