diff --git a/core/sdl/sdl.cpp b/core/sdl/sdl.cpp index 215843642..9027dfa25 100644 --- a/core/sdl/sdl.cpp +++ b/core/sdl/sdl.cpp @@ -766,7 +766,6 @@ static int suspendEventFilter(void *userdata, SDL_Event *event) { if (event->type == SDL_APP_WILLENTERBACKGROUND) { - gui_save(); if (gameRunning) { try { diff --git a/core/ui/boxart/boxart.cpp b/core/ui/boxart/boxart.cpp index dc3f42c32..72c4e4a2d 100644 --- a/core/ui/boxart/boxart.cpp +++ b/core/ui/boxart/boxart.cpp @@ -146,14 +146,12 @@ void Boxart::fetchBoxart() } } } - saveDatabase(true); + saveDatabase(); }); } -void Boxart::saveDatabase(bool internal) +void Boxart::saveDatabase() { - if (!internal && fetching.valid()) - fetching.get(); if (!databaseDirty) return; std::string db_name = getSaveDirectory() + DB_NAME; @@ -216,3 +214,9 @@ void Boxart::loadDatabase() WARN_LOG(COMMON, "Corrupted database file: %s", e.what()); } } + +void Boxart::term() +{ + if (fetching.valid()) + fetching.get(); +} diff --git a/core/ui/boxart/boxart.h b/core/ui/boxart/boxart.h index 2f91dc424..24bcc03b2 100644 --- a/core/ui/boxart/boxart.h +++ b/core/ui/boxart/boxart.h @@ -34,10 +34,11 @@ class Boxart public: GameBoxart getBoxartAndLoad(const GameMedia& media); GameBoxart getBoxart(const GameMedia& media); - void saveDatabase(bool internal = false); + void term(); private: void loadDatabase(); + void saveDatabase(); std::string getSaveDirectory() const { return get_writable_data_path("/boxart/"); } diff --git a/core/ui/gui.cpp b/core/ui/gui.cpp index 6ac9993e7..add088f2b 100644 --- a/core/ui/gui.cpp +++ b/core/ui/gui.cpp @@ -3681,7 +3681,7 @@ void gui_term() EventManager::unlisten(Event::Resume, emuEventCallback); EventManager::unlisten(Event::Start, emuEventCallback); EventManager::unlisten(Event::Terminate, emuEventCallback); - gui_save(); + boxart.term(); } } @@ -3717,11 +3717,6 @@ void gui_error(const std::string& what) error_msg = what; } -void gui_save() -{ - boxart.saveDatabase(); -} - void gui_loadState() { const LockGuard lock(guiMutex); diff --git a/core/ui/gui.h b/core/ui/gui.h index 9c23c38b0..0bb8f645e 100644 --- a/core/ui/gui.h +++ b/core/ui/gui.h @@ -47,7 +47,6 @@ void gui_stop_game(const std::string& message = ""); void gui_start_game(const std::string& path); void gui_error(const std::string& what); void gui_setOnScreenKeyboardCallback(void (*callback)(bool show)); -void gui_save(); void gui_loadState(); void gui_saveState(bool stopRestart = true); std::string gui_getCurGameBoxartUrl(); diff --git a/shell/android-studio/flycast/src/main/jni/src/Android.cpp b/shell/android-studio/flycast/src/main/jni/src/Android.cpp index b8a261e75..0342e99f1 100644 --- a/shell/android-studio/flycast/src/main/jni/src/Android.cpp +++ b/shell/android-studio/flycast/src/main/jni/src/Android.cpp @@ -290,7 +290,6 @@ extern "C" JNIEXPORT void JNICALL Java_com_flycast_emulator_emu_JNIdc_pause(JNIE if (config::AutoSaveState) dc_savestate(config::SavestateSlot); } - gui_save(); } extern "C" JNIEXPORT void JNICALL Java_com_flycast_emulator_emu_JNIdc_resume(JNIEnv *env,jobject obj) diff --git a/shell/apple/emulator-ios/emulator/AppDelegate.mm b/shell/apple/emulator-ios/emulator/AppDelegate.mm index 592f5311e..34840d42a 100644 --- a/shell/apple/emulator-ios/emulator/AppDelegate.mm +++ b/shell/apple/emulator-ios/emulator/AppDelegate.mm @@ -80,7 +80,6 @@ static bool emulatorRunning; { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. - gui_save(); if (config::AutoSaveState && !settings.content.path.empty()) dc_savestate(config::SavestateSlot); }