Skip core unload when Quit on Close Content is set

This commit is contained in:
Jonathan Rascher 2024-06-26 22:17:21 -05:00 committed by LibretroAdmin
parent f4a45a4dd9
commit 8935d9db1b
3 changed files with 13 additions and 7 deletions

View File

@ -5598,9 +5598,10 @@ int action_ok_close_content(const char *path, const char *label, unsigned type,
menu_st->selection_ptr = 0;
/* Check if we need to quit */
check_quit_on_close();
if (should_quit_on_close())
return generic_action_ok_command(CMD_EVENT_QUIT);
/* Unload core */
/* Otherwise, unload core */
ret = generic_action_ok_command(CMD_EVENT_UNLOAD_CORE);
/* If close content was selected via any means other than

View File

@ -3723,6 +3723,12 @@ bool command_event(enum event_command cmd, void *data)
break;
case CMD_EVENT_CLOSE_CONTENT:
#ifdef HAVE_MENU
/* If we need to quit, skip unloading the core to avoid performing
* cleanup actions (like writing autosave state) twice. */
if (should_quit_on_close()) {
command_event(CMD_EVENT_QUIT, NULL);
break;
}
/* Closing content via hotkey requires toggling menu
* and resetting the position later on to prevent
* going to empty Quick Menu */
@ -3731,8 +3737,6 @@ bool command_event(enum event_command cmd, void *data)
menu_state_get_ptr()->flags |= MENU_ST_FLAG_PENDING_CLOSE_CONTENT;
command_event(CMD_EVENT_MENU_TOGGLE, NULL);
}
/* Check if we need to quit Retroarch */
check_quit_on_close();
#else
command_event(CMD_EVENT_QUIT, NULL);
#endif
@ -8212,7 +8216,7 @@ void retroarch_fail(int error_code, const char *error)
}
/* Called on close content, checks if we need to also exit retroarch */
void check_quit_on_close(void)
bool should_quit_on_close(void)
{
#ifdef HAVE_MENU
settings_t *settings = config_get_ptr();
@ -8223,8 +8227,9 @@ void check_quit_on_close(void)
|| (settings->uints.quit_on_close_content ==
QUIT_ON_CLOSE_CONTENT_ENABLED)
)
command_event(CMD_EVENT_QUIT, NULL);
return true;
#endif
return false;
}
/*

View File

@ -206,7 +206,7 @@ void core_options_flush(void);
**/
void retroarch_fail(int error_code, const char *error);
void check_quit_on_close(void);
bool should_quit_on_close(void);
uint16_t retroarch_get_flags(void);