Fix drawable channels remaining in memory after being closed (#5607)

Fix drawable channels remaining in memory after being closed
This commit is contained in:
Dean Herbert 2019-08-06 22:58:14 +09:00 committed by GitHub
commit e3f88a83a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 1 deletions

View File

@ -256,6 +256,9 @@ private void currentChannelChanged(ValueChangedEvent<Channel> e)
loadedChannels.Add(loaded);
LoadComponentAsync(loaded, l =>
{
if (currentChannel.Value != e.NewValue)
return;
loading.Hide();
currentChannelContainer.Clear(false);
@ -381,7 +384,18 @@ private void onChannelRemovedFromJoinedChannels(IEnumerable<Channel> channels)
foreach (Channel channel in channels)
{
ChannelTabControl.RemoveChannel(channel);
loadedChannels.Remove(loadedChannels.Find(c => c.Channel == channel));
var loaded = loadedChannels.Find(c => c.Channel == channel);
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
// to ensure that the previous channel doesn't get updated after it's disposed
currentChannelContainer.Remove(loaded);
loaded.Dispose();
}
}
}