From 52b008dc014e821321de304c5362ab551c5411e3 Mon Sep 17 00:00:00 2001 From: Lars Brinkhoff Date: Mon, 24 Feb 2020 20:58:18 +0100 Subject: [PATCH] DISPLAY: Keep track of device using the display. Don't let someone close the display if they're not the one having opened it. --- display/display.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/display/display.c b/display/display.c index c3abcb5..346f9c7 100644 --- a/display/display.c +++ b/display/display.c @@ -369,6 +369,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" @@ -979,6 +980,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: @@ -992,10 +994,14 @@ display_close(void *dptr) if (!initialized) return; + if (device != dptr) + return; + free (points); ws_shutdown(); initialized = 0; + device = NULL; } void