From 495ed9de99cc6b3b0c08d6524b00903d80cef368 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 13 Sep 2014 17:59:25 -0400 Subject: [PATCH] gfx_common: Make gfx_init_dwm a boolean function Also fixes a bug where inited would be set to true, even if initialization had failed. I don't think it really matters in this case, however if this changes and is called twice for some reason in the future, it won't falsely assume it's already initialized. --- gfx/gfx_common.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/gfx/gfx_common.c b/gfx/gfx_common.c index 32ad3f0581..5fe6f81b35 100644 --- a/gfx/gfx_common.c +++ b/gfx/gfx_common.c @@ -88,19 +88,18 @@ static void gfx_dwm_shutdown(void) dwmlib = NULL; } -static void gfx_init_dwm(void) +static bool gfx_init_dwm(void) { - static bool inited; + static bool inited = false; if (inited) - return; - inited = true; + return true; dwmlib = dylib_load("dwmapi.dll"); if (!dwmlib) { RARCH_LOG("Did not find dwmapi.dll.\n"); - return; + return false; } atexit(gfx_dwm_shutdown); @@ -111,12 +110,14 @@ static void gfx_init_dwm(void) RARCH_LOG("Setting multimedia scheduling for DWM.\n"); mmcss(TRUE); } + + inited = true; + return true; } void gfx_set_dwm(void) { - gfx_init_dwm(); - if (!dwmlib) + if (!gfx_init_dwm()) return; if (g_settings.video.disable_composition == dwm_composition_disabled)