diff --git a/command.c b/command.c index 9651d266b8..19647df0d0 100644 --- a/command.c +++ b/command.c @@ -1756,26 +1756,6 @@ static bool command_event_main_state(unsigned cmd) return ret; } -bool command_event_quit(void) -{ - command_event(CMD_EVENT_AUTOSAVE_STATE, NULL); - command_event(CMD_EVENT_DISABLE_OVERRIDES, NULL); - command_event(CMD_EVENT_RESTORE_DEFAULT_SHADER_PRESET, NULL); - -#ifdef HAVE_DYNAMIC -#ifdef HAVE_MENU - menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_DEINIT, NULL); -#endif -#endif - - runloop_ctl(RUNLOOP_CTL_SET_SHUTDOWN, NULL); -#ifdef HAVE_MENU - rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); -#endif - - return true; -} - static bool command_event_resize_windowed_scale(void) { unsigned idx = 0; @@ -1995,7 +1975,7 @@ bool command_event(enum event_command cmd, void *data) } break; case CMD_EVENT_QUIT: - return command_event_quit(); + return retroarch_main_quit(); case CMD_EVENT_CHEEVOS_HARDCORE_MODE_TOGGLE: #ifdef HAVE_CHEEVOS cheevos_toggle_hardcore_mode(); diff --git a/retroarch.c b/retroarch.c index 2de763d56c..246a373de1 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1676,3 +1676,23 @@ void retroarch_fail(int error_code, const char *error) strlcpy(error_string, error, sizeof(error_string)); longjmp(error_sjlj_context, error_code); } + +bool retroarch_main_quit(void) +{ + command_event(CMD_EVENT_AUTOSAVE_STATE, NULL); + command_event(CMD_EVENT_DISABLE_OVERRIDES, NULL); + command_event(CMD_EVENT_RESTORE_DEFAULT_SHADER_PRESET, NULL); + +#ifdef HAVE_DYNAMIC +#ifdef HAVE_MENU + menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_DEINIT, NULL); +#endif +#endif + + runloop_ctl(RUNLOOP_CTL_SET_SHUTDOWN, NULL); +#ifdef HAVE_MENU + rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); +#endif + + return true; +} diff --git a/retroarch.h b/retroarch.h index 32d9a860aa..5f8a7a29cf 100644 --- a/retroarch.h +++ b/retroarch.h @@ -191,6 +191,8 @@ void retroarch_fail(int error_code, const char *error); **/ bool retroarch_main_init(int argc, char *argv[]); +bool retroarch_main_quit(void); + RETRO_END_DECLS #endif diff --git a/runloop.c b/runloop.c index 73b79ef05b..9a0b9fa29d 100644 --- a/runloop.c +++ b/runloop.c @@ -751,7 +751,10 @@ static enum runloop_state runloop_check_state( content_info.environ_get = NULL; if (!task_push_start_dummy_core(&content_info)) + { + retroarch_main_quit(); return RUNLOOP_STATE_QUIT; + } /* Loads dummy core instead of exiting RetroArch completely. * Aborts core shutdown if invoked. */ @@ -760,7 +763,7 @@ static enum runloop_state runloop_check_state( } else { - command_event_quit(); + retroarch_main_quit(); return RUNLOOP_STATE_QUIT; } }