mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-22 15:11:31 +00:00
[client] overlay: clean up partial initialization
This commit is contained in:
@@ -38,7 +38,7 @@ struct LG_OverlayOps
|
|||||||
/* called when the overlay is registered */
|
/* called when the overlay is registered */
|
||||||
bool (*init)(void ** udata, const void * params);
|
bool (*init)(void ** udata, const void * params);
|
||||||
|
|
||||||
/* final free */
|
/* final free; must be safe if init was not called or returned false */
|
||||||
void (*free)(void * udata);
|
void (*free)(void * udata);
|
||||||
|
|
||||||
/* return true if realtime rendering is required
|
/* return true if realtime rendering is required
|
||||||
|
|||||||
@@ -858,8 +858,6 @@ void app_registerOverlay(const struct LG_OverlayOps * ops, const void * params)
|
|||||||
ops->earlyInit();
|
ops->earlyInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool l_overlaysInitialized = false;
|
|
||||||
|
|
||||||
void app_initOverlays(void)
|
void app_initOverlays(void)
|
||||||
{
|
{
|
||||||
struct Overlay * overlay;
|
struct Overlay * overlay;
|
||||||
@@ -870,12 +868,12 @@ void app_initOverlays(void)
|
|||||||
if (!overlay->ops->init(&overlay->udata, overlay->params))
|
if (!overlay->ops->init(&overlay->udata, overlay->params))
|
||||||
{
|
{
|
||||||
DEBUG_ERROR("Overlay `%s` failed to initialize", overlay->ops->name);
|
DEBUG_ERROR("Overlay `%s` failed to initialize", overlay->ops->name);
|
||||||
|
overlay->ops->free(overlay->udata);
|
||||||
ll_removeNL(g_state.overlays, item);
|
ll_removeNL(g_state.overlays, item);
|
||||||
free(item);
|
free(item);
|
||||||
free(overlay);
|
free(overlay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
l_overlaysInitialized = true;
|
|
||||||
ll_unlock(g_state.overlays);
|
ll_unlock(g_state.overlays);
|
||||||
|
|
||||||
/* Do not seed ImGui's clock with absolute host uptime. ImGui stores the
|
/* Do not seed ImGui's clock with absolute host uptime. ImGui stores the
|
||||||
@@ -1071,11 +1069,9 @@ void app_freeOverlays(void)
|
|||||||
struct Overlay * overlay;
|
struct Overlay * overlay;
|
||||||
while(ll_shift(g_state.overlays, (void **)&overlay))
|
while(ll_shift(g_state.overlays, (void **)&overlay))
|
||||||
{
|
{
|
||||||
if (l_overlaysInitialized)
|
overlay->ops->free(overlay->udata);
|
||||||
overlay->ops->free(overlay->udata);
|
|
||||||
free(overlay);
|
free(overlay);
|
||||||
}
|
}
|
||||||
l_overlaysInitialized = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void app_setOverlay(bool enable)
|
void app_setOverlay(bool enable)
|
||||||
|
|||||||
@@ -60,6 +60,9 @@ static bool config_init(void ** udata, const void * params)
|
|||||||
|
|
||||||
static void config_freeList(struct ll * list)
|
static void config_freeList(struct ll * list)
|
||||||
{
|
{
|
||||||
|
if (!list)
|
||||||
|
return;
|
||||||
|
|
||||||
ConfigCallback * cb;
|
ConfigCallback * cb;
|
||||||
while(ll_shift(list, (void **)&cb))
|
while(ll_shift(list, (void **)&cb))
|
||||||
{
|
{
|
||||||
@@ -73,6 +76,8 @@ static void config_free(void * udata)
|
|||||||
{
|
{
|
||||||
config_freeList(cfg.callbacks);
|
config_freeList(cfg.callbacks);
|
||||||
config_freeList(cfg.tabCallbacks);
|
config_freeList(cfg.tabCallbacks);
|
||||||
|
cfg.callbacks = NULL;
|
||||||
|
cfg.tabCallbacks = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void config_renderLGTab(void)
|
static void config_renderLGTab(void)
|
||||||
|
|||||||
@@ -168,16 +168,26 @@ static bool graphs_init(void ** udata, const void * params)
|
|||||||
|
|
||||||
static void graphs_free(void * udata)
|
static void graphs_free(void * udata)
|
||||||
{
|
{
|
||||||
struct OverlayGraph * graph;
|
if (gs.graphs)
|
||||||
while(ll_shift(gs.graphs, (void **)&graph))
|
{
|
||||||
graphFree(graph);
|
struct OverlayGraph * graph;
|
||||||
ll_free(gs.graphs);
|
while(ll_shift(gs.graphs, (void **)&graph))
|
||||||
gs.graphs = NULL;
|
graphFree(graph);
|
||||||
|
ll_free(gs.graphs);
|
||||||
|
gs.graphs = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
ImPlotSpec_destroy(gs.plotSpec);
|
if (gs.plotSpec)
|
||||||
gs.plotSpec = NULL;
|
{
|
||||||
ImPlot_DestroyContext(gs.plotContext);
|
ImPlotSpec_destroy(gs.plotSpec);
|
||||||
gs.plotContext = NULL;
|
gs.plotSpec = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gs.plotContext)
|
||||||
|
{
|
||||||
|
ImPlot_DestroyContext(gs.plotContext);
|
||||||
|
gs.plotContext = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct BufferMetrics
|
struct BufferMetrics
|
||||||
|
|||||||
@@ -75,10 +75,15 @@ static void freeMsg(struct Msg * msg)
|
|||||||
|
|
||||||
static void msg_free(void * udata)
|
static void msg_free(void * udata)
|
||||||
{
|
{
|
||||||
struct Msg * msg;
|
if (l_msg.messages)
|
||||||
while(ll_shift(l_msg.messages, (void **)&msg))
|
{
|
||||||
freeMsg(msg);
|
struct Msg * msg;
|
||||||
ll_free(l_msg.messages);
|
while(ll_shift(l_msg.messages, (void **)&msg))
|
||||||
|
freeMsg(msg);
|
||||||
|
ll_free(l_msg.messages);
|
||||||
|
l_msg.messages = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
l_msg.initialized = false;
|
l_msg.initialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ static bool splash_init(void ** udata, const void * params)
|
|||||||
static void splash_free(void * udata)
|
static void splash_free(void * udata)
|
||||||
{
|
{
|
||||||
overlayFreeImage(&l_logo);
|
overlayFreeImage(&l_logo);
|
||||||
stringlist_free(&l_tagline );
|
stringlist_free(&l_tagline);
|
||||||
stringlist_free(&l_footline);
|
stringlist_free(&l_footline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ StringList stringlist_new(bool owns_strings)
|
|||||||
|
|
||||||
void stringlist_free(StringList * sl)
|
void stringlist_free(StringList * sl)
|
||||||
{
|
{
|
||||||
|
if (!sl || !*sl)
|
||||||
|
return;
|
||||||
|
|
||||||
stringlist_clear(*sl);
|
stringlist_clear(*sl);
|
||||||
|
|
||||||
vector_destroy(&(*sl)->vector);
|
vector_destroy(&(*sl)->vector);
|
||||||
|
|||||||
Reference in New Issue
Block a user