1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-20 03:47:28 +08:00

Merge pull request #11233 from peppy/fix-chat-threading-crash

Fix potential cross-thread operation during chat channel load
This commit is contained in:
Dean Herbert 2020-12-22 12:10:27 +09:00 committed by GitHub
commit b5e21a6885
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -103,7 +103,7 @@ namespace osu.Game.Overlays.Chat
Colour = colours.ChatBlue.Lighten(0.7f),
};
private void newMessagesArrived(IEnumerable<Message> newMessages)
private void newMessagesArrived(IEnumerable<Message> newMessages) => Schedule(() =>
{
if (newMessages.Min(m => m.Id) < chatLines.Max(c => c.Message.Id))
{
@ -155,9 +155,9 @@ namespace osu.Game.Overlays.Chat
if (shouldScrollToEnd)
scrollToEnd();
}
});
private void pendingMessageResolved(Message existing, Message updated)
private void pendingMessageResolved(Message existing, Message updated) => Schedule(() =>
{
var found = chatLines.LastOrDefault(c => c.Message == existing);
@ -169,12 +169,12 @@ namespace osu.Game.Overlays.Chat
found.Message = updated;
ChatLineFlow.Add(found);
}
}
});
private void messageRemoved(Message removed)
private void messageRemoved(Message removed) => Schedule(() =>
{
chatLines.FirstOrDefault(c => c.Message == removed)?.FadeColour(Color4.Red, 400).FadeOut(600).Expire();
}
});
private IEnumerable<ChatLine> chatLines => ChatLineFlow.Children.OfType<ChatLine>();