boxart: don't save database when pausing (android, uwp)

Avoids ANR on android. Unnecessary since database is now saved
regularly.
This commit is contained in:
Flyinghead 2024-07-20 10:07:18 +02:00
parent 72d9ad34dc
commit 2b83df86cd
7 changed files with 11 additions and 15 deletions

View File

@ -766,7 +766,6 @@ static int suspendEventFilter(void *userdata, SDL_Event *event)
{
if (event->type == SDL_APP_WILLENTERBACKGROUND)
{
gui_save();
if (gameRunning)
{
try {

View File

@ -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();
}

View File

@ -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/");
}

View File

@ -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);

View File

@ -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();

View File

@ -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)

View File

@ -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);
}