1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-11 10:12:58 +08:00

Ensure a DrawableChannel is not attempted to be added after disposal

This commit is contained in:
Dean Herbert 2021-10-04 14:44:16 +09:00
parent 3d71576fbe
commit c6aba3e78b

View File

@ -284,6 +284,10 @@ namespace osu.Game.Overlays
if (currentChannel.Value != e.NewValue) if (currentChannel.Value != e.NewValue)
return; return;
// check once more to ensure the channel hasn't since been removed from the loaded channels like (may have been left by some automated means).
if (loadedChannels.Contains(loaded))
return;
loading.Hide(); loading.Hide();
currentChannelContainer.Clear(false); currentChannelContainer.Clear(false);
@ -426,7 +430,7 @@ namespace osu.Game.Overlays
base.PopOut(); base.PopOut();
} }
private void joinedChannelsChanged(object sender, NotifyCollectionChangedEventArgs args) private void joinedChannelsChanged(object sender, NotifyCollectionChangedEventArgs args) => Schedule(() =>
{ {
switch (args.Action) switch (args.Action)
{ {
@ -444,10 +448,9 @@ namespace osu.Game.Overlays
if (loaded != null) if (loaded != null)
{ {
loadedChannels.Remove(loaded);
// Because the container is only cleared in the async load callback of a new channel, it is forcefully cleared // Because the container is only cleared in the async load callback of a new channel, it is forcefully cleared
// to ensure that the previous channel doesn't get updated after it's disposed // to ensure that the previous channel doesn't get updated after it's disposed
loadedChannels.Remove(loaded);
currentChannelContainer.Remove(loaded); currentChannelContainer.Remove(loaded);
loaded.Dispose(); loaded.Dispose();
} }
@ -455,7 +458,7 @@ namespace osu.Game.Overlays
break; break;
} }
} });
private void availableChannelsChanged(object sender, NotifyCollectionChangedEventArgs args) private void availableChannelsChanged(object sender, NotifyCollectionChangedEventArgs args)
{ {