mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 19:05:37 +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:
commit
0ab0406962
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user