From 99a0766dd99007e37a20d12252ff39451185b264 Mon Sep 17 00:00:00 2001
From: Leon Styhre <leon@leonstyhre.com>
Date: Sun, 30 Jul 2023 00:04:09 +0200
Subject: [PATCH] Changed the 'no games' dialog to no longer save the ROM
 directory to es_settings.xml if its value hasn't changed

---
 es-app/src/views/ViewController.cpp | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/es-app/src/views/ViewController.cpp b/es-app/src/views/ViewController.cpp
index 15cdadf47..3385b7ac5 100644
--- a/es-app/src/views/ViewController.cpp
+++ b/es-app/src/views/ViewController.cpp
@@ -188,22 +188,24 @@ void ViewController::noGamesDialog()
             if (Settings::getInstance()->getBool("VirtualKeyboard")) {
                 mWindow->pushGui(new GuiTextEditKeyboardPopup(
                     HelpStyle(), 0.0f, "ENTER ROM DIRECTORY PATH", currentROMDirectory,
-                    [this](const std::string& newROMDirectory) {
-                        Settings::getInstance()->setString("ROMDirectory",
-                                                           Utils::String::trim(newROMDirectory));
-                        Settings::getInstance()->saveFile();
+                    [this, currentROMDirectory](const std::string& newROMDirectory) {
+                        if (currentROMDirectory != newROMDirectory) {
+                            Settings::getInstance()->setString(
+                                "ROMDirectory", Utils::String::trim(newROMDirectory));
+                            Settings::getInstance()->saveFile();
 #if defined(_WIN64)
-                        mRomDirectory =
-                            Utils::String::replace(FileData::getROMDirectory(), "/", "\\");
+                            mRomDirectory =
+                                Utils::String::replace(FileData::getROMDirectory(), "/", "\\");
 #else
-                        mRomDirectory = FileData::getROMDirectory();
+                            mRomDirectory = FileData::getROMDirectory();
 #endif
-                        mNoGamesMessageBox->changeText(mNoGamesErrorMessage + mRomDirectory);
-                        mWindow->pushGui(new GuiMsgBox(HelpStyle(),
-                                                       "ROM DIRECTORY SETTING SAVED, RESTART\n"
-                                                       "THE APPLICATION TO RESCAN THE SYSTEMS",
-                                                       "OK", nullptr, "", nullptr, "", nullptr,
-                                                       true, true));
+                            mNoGamesMessageBox->changeText(mNoGamesErrorMessage + mRomDirectory);
+                            mWindow->pushGui(new GuiMsgBox(HelpStyle(),
+                                                           "ROM DIRECTORY SETTING SAVED, RESTART\n"
+                                                           "THE APPLICATION TO RESCAN THE SYSTEMS",
+                                                           "OK", nullptr, "", nullptr, "", nullptr,
+                                                           true, true));
+                        }
                     },
                     false, "SAVE", "SAVE CHANGES?", "Currently configured path:",
                     currentROMDirectory, "LOAD CURRENTLY CONFIGURED PATH",