Schedule adding transforms on tablet changes

Fixes `InvalidThreadForMutationException`s that pop up when
disconnecting/reconnecting tablets during the game's operation. In those
cases the value change callback executes from  an OpenTabletDriver
thread.
This commit is contained in:
Bartłomiej Dach
2021-03-20 12:29:24 +01:00
parent b9b351311a
commit d28bed6ed2
2 changed files with 26 additions and 14 deletions

View File

@ -196,19 +196,13 @@ namespace osu.Game.Overlays.Settings.Sections.Input
tablet.BindTo(tabletHandler.Tablet);
tablet.BindValueChanged(val =>
{
Scheduler.AddOnce(toggleVisibility);
var tab = val.NewValue;
bool tabletFound = tab != null;
if (!tabletFound)
{
mainSettings.Hide();
noTabletMessage.Show();
return;
}
mainSettings.Show();
noTabletMessage.Hide();
offsetX.MaxValue = tab.Size.X;
offsetX.Default = tab.Size.X / 2;
@ -222,6 +216,21 @@ namespace osu.Game.Overlays.Settings.Sections.Input
}, true);
}
private void toggleVisibility()
{
bool tabletFound = tablet.Value != null;
if (!tabletFound)
{
mainSettings.Hide();
noTabletMessage.Show();
return;
}
mainSettings.Show();
noTabletMessage.Hide();
}
private void applyAspectRatio(BindableNumber<float> sizeChanged)
{
try