Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silently return rather than throwing when performing mutations on disposed drawables #5534

Merged
merged 4 commits into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 0 additions & 1 deletion osu.Framework.Tests/Containers/TestSceneContainerState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public void TestAttemptAddAfterDisposal()
Assert.IsFalse(container.Contains(sprite));

// Attempts re-add
Assert.Throws<ObjectDisposedException>(() => container.Add(sprite));
Assert.IsFalse(container.Contains(sprite));
}

Expand Down
10 changes: 5 additions & 5 deletions osu.Framework/Graphics/Containers/CompositeDrawable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ private void loadChild(Drawable child)
try
{
if (IsDisposed)
throw new ObjectDisposedException(ToString(), "Disposed drawables may not have children added.");
return;

child.Load(Clock, Dependencies, false);

Expand Down Expand Up @@ -367,7 +367,7 @@ protected internal Drawable InternalChild
set
{
if (IsDisposed)
throw new ObjectDisposedException(ToString(), "Disposed drawables may not have children set.");
return;

ClearInternal();
AddInternal(value);
Expand Down Expand Up @@ -439,7 +439,7 @@ protected internal IEnumerable<Drawable> InternalChildrenEnumerable
set
{
if (IsDisposed)
throw new ObjectDisposedException(ToString(), "Children cannot be mutated on a disposed drawable.");
return;

ClearInternal();
AddRangeInternal(value);
Expand Down Expand Up @@ -537,7 +537,7 @@ protected internal virtual void ClearInternal(bool disposeChildren = true)
EnsureChildMutationAllowed();

if (IsDisposed)
throw new ObjectDisposedException(ToString(), "Children cannot be cleared on a disposed drawable.");
return;

if (internalChildren.Count == 0) return;

Expand Down Expand Up @@ -578,7 +578,7 @@ protected virtual void AddInternal(Drawable drawable)
EnsureChildMutationAllowed();

if (IsDisposed)
throw new ObjectDisposedException(ToString(), "Children cannot be mutated on a disposed drawable.");
return;

if (drawable == null)
throw new ArgumentNullException(nameof(drawable), $"null {nameof(Drawable)}s may not be added to {nameof(CompositeDrawable)}.");
Expand Down
4 changes: 2 additions & 2 deletions osu.Framework/Graphics/Containers/Container.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public IEnumerable<T> ChildrenEnumerable
set
{
if (IsDisposed)
throw new ObjectDisposedException(ToString(), "Children cannot be mutated on a disposed drawable.");
return;

Clear();
AddRange(value);
Expand All @@ -171,7 +171,7 @@ public T Child
set
{
if (IsDisposed)
throw new ObjectDisposedException(ToString(), "Children cannot be mutated on a disposed drawable.");
return;

Clear();
Add(value);
Expand Down