13
0

LXVST: fix crash at exit if Linux VSTs are disabled or X11 connection fails

This commit is contained in:
Robin Gareus 2024-08-28 04:10:41 +02:00
parent c77d2d42b9
commit 79e2ffff2a
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -58,7 +58,7 @@ static VSTState * vstfx_first = NULL;
const char magic[] = "VSTFX Plugin State v002";
static volatile int gui_quit = 0;
static volatile int gui_state = -1;
/*This will be our connection to X*/
@ -330,7 +330,7 @@ gui_event_loop (void* ptr)
clock1 = g_get_monotonic_time();
/*The 'Forever' loop - runs the plugin UIs etc - based on the FST gui event loop*/
while (!gui_quit)
while (gui_state == 0)
{
/* handle window creation requests, destroy requests,
and run idle callbacks */
@ -464,7 +464,7 @@ again:
clock1 = g_get_monotonic_time();
}
if (!gui_quit && may_sleep && elapsed_time_ms + 1 < LXVST_sched_timer_interval) {
if (0 == gui_state && may_sleep && elapsed_time_ms + 1 < LXVST_sched_timer_interval) {
Glib::usleep (1000 * (LXVST_sched_timer_interval - elapsed_time_ms - 1));
}
}
@ -506,7 +506,7 @@ normally started in globals.cc*/
int vstfx_init (void* ptr)
{
assert (gui_quit == 0);
assert (gui_state == -1);
pthread_mutex_init (&plugin_mutex, NULL);
int thread_create_result;
@ -542,6 +542,7 @@ int vstfx_init (void* ptr)
}
/*We have a connection to X - so start the gui event loop*/
gui_state = 0;
/*Create the thread - use default attrs for now, don't think we need anything special*/
@ -555,7 +556,7 @@ int vstfx_init (void* ptr)
XCloseDisplay (LXVST_XDisplay);
LXVST_XDisplay = 0;
gui_quit = 1;
gui_state = 1;
return -1;
}
@ -567,10 +568,10 @@ int vstfx_init (void* ptr)
void vstfx_exit ()
{
if (gui_quit) {
if (gui_state) {
return;
}
gui_quit = 1;
gui_state = 1;
/*We need to pthread_join the gui_thread here so
we know when it has stopped*/