1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 17:47:29 +08:00

Fix disposal issues in ChatOverlay testcase

This commit is contained in:
Dean Herbert 2018-09-06 15:56:04 +09:00
parent ce92c8d2eb
commit 119f81b86e

View File

@ -339,13 +339,26 @@ namespace osu.Game.Overlays
this.channelManager = channelManager;
channelManager.CurrentChannel.ValueChanged += currentChannelChanged;
channelManager.JoinedChannels.CollectionChanged += joinedChannelsChanged;
channelManager.AvailableChannels.CollectionChanged += (sender, args) => channelSelection.UpdateAvailableChannels(channelManager.AvailableChannels);
channelManager.AvailableChannels.CollectionChanged += availableChannelsChanged;
//for the case that channelmanager was faster at fetching the channels than our attachment to CollectionChanged.
channelSelection.UpdateAvailableChannels(channelManager.AvailableChannels);
joinedChannelsChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, channelManager.JoinedChannels));
}
private void availableChannelsChanged(object sender, NotifyCollectionChangedEventArgs e)
{
channelSelection.UpdateAvailableChannels(channelManager.AvailableChannels);
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
channelManager.CurrentChannel.ValueChanged -= currentChannelChanged;
channelManager.JoinedChannels.CollectionChanged -= joinedChannelsChanged;
channelManager.AvailableChannels.CollectionChanged -= availableChannelsChanged;
}
private void postMessage(TextBox textbox, bool newText)
{
var text = textbox.Text.Trim();