From 7676a88d54a9dc3090ad83ec746349f795aaa1d4 Mon Sep 17 00:00:00 2001 From: Daniel Stuart Baxter Date: Sun, 30 Jul 2023 15:51:01 -0500 Subject: [PATCH] [Qt] Properly save backups when opening another ROM file. Fixes Issue #149 --- src/qt/main_menu.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/qt/main_menu.cpp b/src/qt/main_menu.cpp index 99c0c195..5d1de2c4 100644 --- a/src/qt/main_menu.cpp +++ b/src/qt/main_menu.cpp @@ -343,13 +343,18 @@ void main_menu::open_file() { SDL_PauseAudio(1); + std::string next_rom_file = ""; + std::string next_save_file = ""; + bool use_next_files = false; + if(config::cli_args.empty()) { QString filename = QFileDialog::getOpenFileName(this, tr("Open"), "", tr("GBx/NDS/MIN/AM3 files (*.gb *.gbc *.gba *.nds *.min *.am3)")); if(filename.isNull()) { SDL_PauseAudio(0); return; } - config::rom_file = filename.toStdString(); - config::save_file = util::get_filename_no_ext(config::rom_file) + ".sav"; + next_rom_file = filename.toStdString(); + next_save_file = util::get_filename_no_ext(next_rom_file) + ".sav"; + use_next_files = true; } else @@ -367,6 +372,12 @@ void main_menu::open_file() main_menu::gbe_plus->core_emu::~core_emu(); } + if(use_next_files) + { + config::rom_file = next_rom_file; + config::save_file = next_save_file; + } + config::sdl_render = false; config::render_external_sw = render_screen_sw; config::render_external_hw = render_screen_hw;