1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 05:02:55 +08:00

Fix user bindable being written to from background thread (#4742)

Fix user bindable being written to from background thread
This commit is contained in:
Dean Herbert 2019-05-09 14:00:45 +09:00 committed by GitHub
commit 0ab0406962
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -77,13 +77,13 @@ namespace osu.Game.Online.API
/// <param name="component"></param>
public void Register(IOnlineComponent component)
{
Scheduler.Add(delegate { components.Add(component); });
Schedule(() => components.Add(component));
component.APIStateChanged(this, state);
}
public void Unregister(IOnlineComponent component)
{
Scheduler.Add(delegate { components.Remove(component); });
Schedule(() => components.Remove(component));
}
public string AccessToken => authentication.RequestAccessToken();
@ -274,7 +274,7 @@ namespace osu.Game.Online.API
state = value;
log.Add($@"We just went {state}!");
Scheduler.Add(delegate
Schedule(() =>
{
components.ForEach(c => c.APIStateChanged(this, state));
OnStateChange?.Invoke(oldState, state);
@ -352,9 +352,13 @@ namespace osu.Game.Online.API
public void Logout()
{
flushQueue();
password = null;
authentication.Clear();
LocalUser.Value = createGuestUser();
// Scheduled prior to state change such that the state changed event is invoked with the correct user present
Schedule(() => LocalUser.Value = createGuestUser());
State = APIState.Offline;
}