mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-22 07:01:30 +00:00
[client] app: free overlays after display server shutdown
Some checks failed
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / module (push) Has been cancelled
build / host-linux (push) Has been cancelled
build / host-windows-cross (push) Has been cancelled
build / host-windows-native (push) Has been cancelled
build / idd (push) Has been cancelled
build / obs (clang) (push) Has been cancelled
build / obs (gcc) (push) Has been cancelled
build / docs (push) Has been cancelled
Some checks failed
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / module (push) Has been cancelled
build / host-linux (push) Has been cancelled
build / host-windows-cross (push) Has been cancelled
build / host-windows-native (push) Has been cancelled
build / idd (push) Has been cancelled
build / obs (clang) (push) Has been cancelled
build / obs (gcc) (push) Has been cancelled
build / docs (push) Has been cancelled
The render thread freed the overlays as soon as it exited, while the main thread could still be dispatching display server input callbacks that iterate them. Free the overlays in lg_shutdown instead, once the render thread has been joined and the display server has shut down. The overlays now outlive the renderer, so overlayFreeImage must not call into it; renderer deinitialization has already destroyed all textures along with the context.
This commit is contained in:
committed by
Geoffrey McRae
parent
75f7d614a7
commit
8187177c7f
@@ -858,6 +858,8 @@ 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;
|
||||||
@@ -868,9 +870,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 = NULL;
|
ll_removeNL(g_state.overlays, item);
|
||||||
|
free(item);
|
||||||
|
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
|
||||||
@@ -1066,9 +1071,11 @@ 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))
|
||||||
{
|
{
|
||||||
overlay->ops->free(overlay->udata);
|
if (l_overlaysInitialized)
|
||||||
|
overlay->ops->free(overlay->udata);
|
||||||
free(overlay);
|
free(overlay);
|
||||||
}
|
}
|
||||||
|
l_overlaysInitialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void app_setOverlay(bool enable)
|
void app_setOverlay(bool enable)
|
||||||
|
|||||||
@@ -1078,13 +1078,6 @@ static int renderThread(void * unused)
|
|||||||
|
|
||||||
app_setState(APP_STATE_SHUTDOWN);
|
app_setState(APP_STATE_SHUTDOWN);
|
||||||
|
|
||||||
if (g_state.overlays)
|
|
||||||
{
|
|
||||||
app_freeOverlays();
|
|
||||||
ll_free(g_state.overlays);
|
|
||||||
g_state.overlays = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
lgTimerDestroy(tickTimer);
|
lgTimerDestroy(tickTimer);
|
||||||
lgTimerDestroy(fpsTimer);
|
lgTimerDestroy(fpsTimer);
|
||||||
|
|
||||||
@@ -3505,6 +3498,9 @@ static void lg_shutdown(void)
|
|||||||
}
|
}
|
||||||
LG_LOCK_FREE(l_cursorRepaint.lock);
|
LG_LOCK_FREE(l_cursorRepaint.lock);
|
||||||
|
|
||||||
|
// An evdev batch may call input handlers; join before input teardown
|
||||||
|
evdev_stop();
|
||||||
|
|
||||||
if (g_state.transport.ops)
|
if (g_state.transport.ops)
|
||||||
{
|
{
|
||||||
lgInput_dropTransport();
|
lgInput_dropTransport();
|
||||||
@@ -3540,6 +3536,7 @@ static void lg_shutdown(void)
|
|||||||
|
|
||||||
if (g_state.ds)
|
if (g_state.ds)
|
||||||
g_state.ds->shutdown();
|
g_state.ds->shutdown();
|
||||||
|
|
||||||
lgClipboard_free();
|
lgClipboard_free();
|
||||||
|
|
||||||
app_releaseAllKeybinds();
|
app_releaseAllKeybinds();
|
||||||
@@ -3548,6 +3545,16 @@ static void lg_shutdown(void)
|
|||||||
if (g_state.ds && g_state.dsInitialized)
|
if (g_state.ds && g_state.dsInitialized)
|
||||||
g_state.ds->free();
|
g_state.ds->free();
|
||||||
|
|
||||||
|
// Input callbacks have stopped; the evdev state and overlays can go
|
||||||
|
evdev_free();
|
||||||
|
|
||||||
|
if (g_state.overlays)
|
||||||
|
{
|
||||||
|
app_freeOverlays();
|
||||||
|
ll_free(g_state.overlays);
|
||||||
|
g_state.overlays = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
renderQueue_setSourceFns(NULL, NULL, NULL);
|
renderQueue_setSourceFns(NULL, NULL, NULL);
|
||||||
renderQueue_free();
|
renderQueue_free();
|
||||||
LG_LOCK_FREE(g_state.videoSourceLock);
|
LG_LOCK_FREE(g_state.videoSourceLock);
|
||||||
|
|||||||
@@ -182,5 +182,9 @@ void overlayFreeImage(OverlayImage * image)
|
|||||||
if (!image->tex)
|
if (!image->tex)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RENDERER(freeTexture, image->tex);
|
// During shutdown the renderer is freed first, taking all textures with it
|
||||||
|
if (g_state.lgr)
|
||||||
|
RENDERER(freeTexture, image->tex);
|
||||||
|
|
||||||
|
image->tex = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user