From 19d006d8182812710bffd94d26a4fb2512c101cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 25 Apr 2024 12:51:30 +0200 Subject: [PATCH] Fix deleting modified difficulty via editor leaving user in broken state Closes https://github.com/ppy/osu/issues/22783. If the difficulty being edited has unsaved changes, the editor exit flow would prompt for save *after* the deletion method has run. This is undesirable from a UX standpoint, and also leaves the user in a broken state. Thus, just fake an update of the last saved hash of the beatmap to fool the editor into thinking that it's not dirty, so that the exit flow will not show a save dialog. --- osu.Game/Screens/Edit/Editor.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 37f4b4f5be..980c613311 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -1088,6 +1088,13 @@ void delete() var difficultiesBeforeDeletion = groupedOrderedBeatmaps.SelectMany(g => g).ToList(); + // if the difficulty being currently deleted has unsaved changes, + // the editor exit flow would prompt for save *after* this method has done its thing. + // this is generally undesirable and also ends up leaving the user in a broken state. + // therefore, just update the last saved hash to make the exit flow think the deleted beatmap is not dirty, + // so that it will not show the save dialog on exit. + updateLastSavedHash(); + beatmapManager.DeleteDifficultyImmediately(difficultyToDelete); int deletedIndex = difficultiesBeforeDeletion.IndexOf(difficultyToDelete);