DISPLAY: Keep track of device using the display.

Don't let someone close the display if they're not the one having
opened it.
This commit is contained in:
Lars Brinkhoff 2020-02-24 20:58:18 +01:00
parent 26fa91a335
commit f5a9bed34c

View file

@ -359,6 +359,7 @@ static long queue_interval;
#define Y(P) (((P) - points) / xpixels)
static int initialized = 0;
static void *device = NULL; /* Current display device. */
/*
* global set by O/S display level to indicate "light pen tip switch activated"
@ -969,6 +970,7 @@ display_init(enum display_type type, int sf, void *dptr)
initialized = 1;
init_failed = 0; /* hey, we made it! */
device = dptr;
return 1;
failed:
@ -982,10 +984,14 @@ display_close(void *dptr)
if (!initialized)
return;
if (device != dptr)
return;
free (points);
ws_shutdown();
initialized = 0;
device = NULL;
}
void