From 09bebefceefed31e7c9d0ee970878162dbd9a89e Mon Sep 17 00:00:00 2001 From: Dmugetsu Date: Fri, 14 Feb 2025 23:27:58 -0600 Subject: [PATCH] Test 2 --- src/emulator.cpp | 3 ++- src/emulator.h | 3 +++ src/qt_gui/main_window.cpp | 26 +++++++++++++++++--------- src/qt_gui/main_window.h | 3 +++ 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/emulator.cpp b/src/emulator.cpp index 3ae745a1e..1e9a4fd81 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -295,6 +295,7 @@ void Emulator::Run(const std::filesystem::path& file, const std::vector recentFiles = Config::getRecentFiles(); - if (recentFiles.empty()) { + if (lastGamePath.empty()) { QMessageBox::warning(this, tr("Restart Game"), tr("No recent game found.")); return; } - QString lastGamePath = QString::fromStdString(recentFiles.front()); - - // Stop the current game first + // Stop the current game properly StopGame(); - // Wait for cleanup - QThread::sleep(1); + // Ensure the game has fully stopped before restarting + while (isGameRunning) { + QCoreApplication::processEvents(); + QThread::msleep(100); // Small delay to allow cleanup + } - // Restart the game - StartEmulator(Common::FS::PathFromQString(lastGamePath)); + // Restart the emulator with the last played game + StartEmulator(lastGamePath); } +#endif diff --git a/src/qt_gui/main_window.h b/src/qt_gui/main_window.h index 69d5d8800..f3cbe6b6d 100644 --- a/src/qt_gui/main_window.h +++ b/src/qt_gui/main_window.h @@ -67,7 +67,10 @@ private: void SetUiIcons(bool isWhite); void InstallPkg(); void BootGame(); +#ifdef ENABLE_QT_GUI QString getLastEbootPath(); + std::filesystem::path lastGamePath; +#endif void AddRecentFiles(QString filePath); void LoadTranslation(); void PlayBackgroundMusic();