1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 09:42:54 +08:00

Fix potential editor data loss if exiting while a textbox is focused

This commit is contained in:
Dean Herbert 2024-01-26 13:23:02 +09:00
parent e54502eef1
commit 45f2980dc0
No known key found for this signature in database
2 changed files with 11 additions and 5 deletions

View File

@ -719,6 +719,12 @@ namespace osu.Game.Screens.Edit
public override bool OnExiting(ScreenExitEvent e)
{
// Before exiting, trigger a focus loss.
//
// This is important to ensure that if the user is still editing a textbox, it will commit
// (and potentially block the exit procedure for save).
GetContainingInputManager().TriggerFocusContention(this);
if (!ExitConfirmed)
{
// dialog overlay may not be available in visual tests.

View File

@ -53,9 +53,6 @@ namespace osu.Game.Screens.Edit.Setup
sourceTextBox = createTextBox<LabelledTextBox>(BeatmapsetsStrings.ShowInfoSource, metadata.Source),
tagsTextBox = createTextBox<LabelledTextBox>(BeatmapsetsStrings.ShowInfoTags, metadata.Tags)
};
foreach (var item in Children.OfType<LabelledTextBox>())
item.OnCommit += onCommit;
}
private TTextBox createTextBox<TTextBox>(LocalisableString label, string initialValue)
@ -77,6 +74,10 @@ namespace osu.Game.Screens.Edit.Setup
ArtistTextBox.Current.BindValueChanged(artist => transferIfRomanised(artist.NewValue, RomanisedArtistTextBox));
TitleTextBox.Current.BindValueChanged(title => transferIfRomanised(title.NewValue, RomanisedTitleTextBox));
foreach (var item in Children.OfType<LabelledTextBox>())
item.OnCommit += onCommit;
updateReadOnlyState();
}
@ -86,7 +87,6 @@ namespace osu.Game.Screens.Edit.Setup
target.Current.Value = value;
updateReadOnlyState();
Scheduler.AddOnce(updateMetadata);
}
private void updateReadOnlyState()
@ -101,7 +101,7 @@ namespace osu.Game.Screens.Edit.Setup
// for now, update on commit rather than making BeatmapMetadata bindables.
// after switching database engines we can reconsider if switching to bindables is a good direction.
Scheduler.AddOnce(updateMetadata);
updateMetadata();
}
private void updateMetadata()