From f1081db953887ba597675c772772d5a8ca94acff Mon Sep 17 00:00:00 2001
From: Salman Ahmed <frenzibyte@gmail.com>
Date: Thu, 16 Jun 2022 18:48:32 +0300
Subject: [PATCH] Fix background/track implicitly renamed on initial load

---
 .../Screens/Edit/Setup/ResourcesSection.cs    | 35 ++++++++++---------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/osu.Game/Screens/Edit/Setup/ResourcesSection.cs b/osu.Game/Screens/Edit/Setup/ResourcesSection.cs
index 2471886d9b..5054f7a393 100644
--- a/osu.Game/Screens/Edit/Setup/ResourcesSection.cs
+++ b/osu.Game/Screens/Edit/Setup/ResourcesSection.cs
@@ -59,8 +59,10 @@ namespace osu.Game.Screens.Edit.Setup
             if (!string.IsNullOrEmpty(working.Value.Metadata.AudioFile))
                 audioTrackChooser.Current.Value = new FileInfo(working.Value.Metadata.AudioFile);
 
-            backgroundChooser.Current.BindValueChanged(backgroundChanged, true);
-            audioTrackChooser.Current.BindValueChanged(audioTrackChanged, true);
+            backgroundChooser.Current.BindValueChanged(backgroundChanged);
+            audioTrackChooser.Current.BindValueChanged(audioTrackChanged);
+
+            updatePlaceholderText();
         }
 
         public bool ChangeBackgroundImage(FileInfo source)
@@ -121,28 +123,29 @@ namespace osu.Game.Screens.Edit.Setup
 
         private void backgroundChanged(ValueChangedEvent<FileInfo> file)
         {
-            backgroundChooser.Text = file.NewValue == null
-                ? "Click to select a background image"
-                : "Click to replace the background image";
+            if (!ChangeBackgroundImage(file.NewValue))
+                backgroundChooser.Current.Value = file.OldValue;
 
-            if (file.NewValue != file.OldValue)
-            {
-                if (!ChangeBackgroundImage(file.NewValue))
-                    backgroundChooser.Current.Value = file.OldValue;
-            }
+            updatePlaceholderText();
         }
 
         private void audioTrackChanged(ValueChangedEvent<FileInfo> file)
         {
-            audioTrackChooser.Text = file.NewValue == null
+            if (!ChangeAudioTrack(file.NewValue))
+                audioTrackChooser.Current.Value = file.OldValue;
+
+            updatePlaceholderText();
+        }
+
+        private void updatePlaceholderText()
+        {
+            audioTrackChooser.Text = audioTrackChooser.Current.Value == null
                 ? "Click to select a track"
                 : "Click to replace the track";
 
-            if (file.NewValue != file.OldValue)
-            {
-                if (!ChangeAudioTrack(file.NewValue))
-                    audioTrackChooser.Current.Value = file.OldValue;
-            }
+            backgroundChooser.Text = backgroundChooser.Current.Value == null
+                ? "Click to select a background image"
+                : "Click to replace the background image";
         }
     }
 }