Turn global->content.inited into static local variable

and go through content_ctl
This commit is contained in:
twinaphex 2016-01-19 22:57:18 +01:00
parent 748959c8fc
commit a5af9b653a
5 changed files with 21 additions and 16 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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,

View File

@ -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,

View File

@ -285,7 +285,6 @@ typedef struct global
struct
{
bool main;
bool content;
struct
{
bool no_content;