diff --git a/command_event.c b/command_event.c index abd1ff5a19..ee68c978ee 100644 --- a/command_event.c +++ b/command_event.c @@ -1482,7 +1482,7 @@ bool event_command(enum event_command cmd) input_driver_ctl(RARCH_INPUT_CTL_REMOTE_INIT, NULL); break; case EVENT_CMD_TEMPORARY_CONTENT_DEINIT: - content_ctl(CONTENT_CTL_TEMPORARY_FREE, NULL); + content_ctl(CONTENT_CTL_DEINIT, NULL); break; case EVENT_CMD_SUBSYSTEM_FULLPATHS_DEINIT: if (!global) diff --git a/content.c b/content.c index 82352d2b37..ddf212bf03 100644 --- a/content.c +++ b/content.c @@ -753,6 +753,7 @@ bool content_ctl(enum content_ctl_state state, void *data) { unsigned i; static struct string_list *temporary_content = NULL; + static bool content_is_inited = false; switch(state) { @@ -770,17 +771,20 @@ bool content_ctl(enum content_ctl_state state, void *data) return false; return content_save_state(path); } + case CONTENT_CTL_IS_INITED: + return content_is_inited; + case CONTENT_CTL_DEINIT: + content_ctl(CONTENT_CTL_TEMPORARY_FREE, NULL); + content_is_inited = false; + return true; case CONTENT_CTL_INIT: + content_is_inited = false; + if (content_init_file(temporary_content)) { - global_t *global = global_get_ptr(); - if (content_init_file(temporary_content)) - { - global->inited.content = true; - return true; - } - global->inited.content = false; - /* fall-through */ + content_is_inited = true; + return true; } + /* fall-through */ case CONTENT_CTL_TEMPORARY_FREE: if (!temporary_content) return false; diff --git a/content.h b/content.h index 070ab83d0e..a8403abe72 100644 --- a/content.h +++ b/content.h @@ -31,10 +31,14 @@ enum content_ctl_state { CONTENT_CTL_NONE = 0, + CONTENT_CTL_IS_INITED, + /* Initializes and loads a content file for the currently * selected libretro core. */ CONTENT_CTL_INIT, + CONTENT_CTL_DEINIT, + /* Load a state from disk to memory. */ CONTENT_CTL_LOAD_STATE, diff --git a/frontend/frontend.c b/frontend/frontend.c index 1399e890e5..3a559401f2 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -27,6 +27,7 @@ #include "../ui/ui_companion_driver.h" #include "../defaults.h" +#include "../content.h" #include "../driver.h" #include "../system.h" #include "../driver.h" @@ -60,11 +61,10 @@ int rarch_main_async_job_add(async_task_t task, void *payload) void main_exit(void *args) { settings_t *settings = config_get_ptr(); - global_t *global = global_get_ptr(); event_command(EVENT_CMD_MENU_SAVE_CURRENT_CONFIG); - if (global->inited.main) + if (content_ctl(CONTENT_CTL_IS_INITED, NULL)) { #ifdef HAVE_MENU /* Do not want menu context to live any more. */ @@ -288,14 +288,12 @@ int rarch_main(int argc, char *argv[], void *data) if (settings->history_list_enable) { char *fullpath = NULL; - global_t *global = global_get_ptr(); rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); - + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); - if (global->inited.content || system->no_content) + if (content_ctl(CONTENT_CTL_IS_INITED, NULL) || system->no_content) history_playlist_push( g_defaults.history, fullpath, diff --git a/runloop.h b/runloop.h index d078e6b3ab..94a50d18ae 100644 --- a/runloop.h +++ b/runloop.h @@ -285,7 +285,6 @@ typedef struct global struct { bool main; - bool content; struct { bool no_content;