Fix quit on content close option (#16014)

Right now close is based on core unload. There are several places where
cores are unloaded without the intention of stopping the emulation (for
instance whenever Netplay is started, core is updated, etc).

Moreover scheduling a quit under some of those events causes a task
queue deadlock (as per issue #15313) and freezed retroarch.

This fix moves the quit on close to a "manual" check, placed in the
relevant places (close content menu option, close content event (which
also covers hotkeys), etc.)
This commit is contained in:
David G. F 2023-12-21 01:23:18 +01:00 committed by GitHub
parent 93f7bba6a5
commit 3194dc9d65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 9 deletions

View file

@ -5572,6 +5572,8 @@ int action_ok_close_content(const char *path, const char *label, unsigned type,
menu_st->flags &= ~MENU_ST_FLAG_PREVENT_POPULATE;
}
check_quit_on_close();
return ret;
}

View file

@ -3645,15 +3645,6 @@ bool command_event(enum event_command cmd, void *data)
if ( (flags & CONTENT_ST_FLAG_IS_INITED)
&& load_dummy_core)
{
#ifdef HAVE_MENU
if ( ((settings->uints.quit_on_close_content ==
QUIT_ON_CLOSE_CONTENT_CLI)
&& global->launched_from_cli)
|| (settings->uints.quit_on_close_content ==
QUIT_ON_CLOSE_CONTENT_ENABLED)
)
command_event(CMD_EVENT_QUIT, NULL);
#endif
if (!task_push_start_dummy_core(&content_info))
return false;
}
@ -3693,6 +3684,8 @@ 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
@ -8020,6 +8013,22 @@ void retroarch_fail(int error_code, const char *error)
longjmp(global->error_sjlj_context, error_code);
}
/* Called on close content, checks if we need to also exit retroarch */
void check_quit_on_close(void)
{
#ifdef HAVE_MENU
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
if ( ((settings->uints.quit_on_close_content ==
QUIT_ON_CLOSE_CONTENT_CLI)
&& global->launched_from_cli)
|| (settings->uints.quit_on_close_content ==
QUIT_ON_CLOSE_CONTENT_ENABLED)
)
command_event(CMD_EVENT_QUIT, NULL);
#endif
}
/*
* Also saves configuration files to disk,
* and (optionally) autosave state.

View file

@ -206,6 +206,8 @@ void core_options_flush(void);
**/
void retroarch_fail(int error_code, const char *error);
void check_quit_on_close(void);
uint16_t retroarch_get_flags(void);
RETRO_END_DECLS