mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
Ensure save states are correctly flushed to disk when quitting RetroArch (fixes broken save states when exiting RetroArch - without first closing content - with 'Auto Save State' enabled)
This commit is contained in:
parent
ba0d5705fc
commit
6083450d4e
@ -51,6 +51,9 @@ bool content_load_state(const char* path, bool load_to_backup_buffer, bool autol
|
||||
/* Save a state from memory to disk. */
|
||||
bool content_save_state(const char *path, bool save_to_disk, bool autosave);
|
||||
|
||||
/* Returns true if a save state task is in progress */
|
||||
bool content_save_state_in_progress(void);
|
||||
|
||||
/* Copy a save state. */
|
||||
bool content_rename_state(const char *origin, const char *dest);
|
||||
|
||||
|
@ -7771,6 +7771,7 @@ bool command_event(enum event_command cmd, void *data)
|
||||
|
||||
command_event_runtime_log_deinit();
|
||||
command_event_save_auto_state();
|
||||
|
||||
#ifdef HAVE_CONFIGFILE
|
||||
if (p_rarch->runloop_overrides_active)
|
||||
command_event_disable_overrides();
|
||||
@ -28956,6 +28957,13 @@ bool retroarch_main_quit(void)
|
||||
if (!p_rarch->runloop_shutdown_initiated)
|
||||
{
|
||||
command_event_save_auto_state();
|
||||
|
||||
/* If any save states are in progress, wait
|
||||
* until all tasks are complete (otherwise
|
||||
* save state file may be truncated) */
|
||||
if (content_save_state_in_progress())
|
||||
task_queue_wait(NULL, NULL);
|
||||
|
||||
#ifdef HAVE_CONFIGFILE
|
||||
if (p_rarch->runloop_overrides_active)
|
||||
command_event_disable_overrides();
|
||||
|
@ -1352,6 +1352,31 @@ bool content_save_state(const char *path, bool save_to_disk, bool autosave)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool task_save_state_finder(retro_task_t *task, void *user_data)
|
||||
{
|
||||
if (!task)
|
||||
return false;
|
||||
|
||||
if (task->handler == task_save_handler)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Returns true if a save state task is in progress */
|
||||
bool content_save_state_in_progress(void)
|
||||
{
|
||||
task_finder_data_t find_data;
|
||||
|
||||
find_data.func = task_save_state_finder;
|
||||
find_data.userdata = NULL;
|
||||
|
||||
if (task_queue_find(&find_data))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* content_load_state:
|
||||
* @path : path that state will be loaded from.
|
||||
|
Loading…
x
Reference in New Issue
Block a user