From e4ef7d4dc1ae7a8c27ee6cbe6d304cee3212da5d Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Tue, 12 Mar 2024 12:03:53 +0100 Subject: [PATCH] replace cairo_image_surface_create_for_data with cairo_image_surface_create in create_memory_cairo_ctx --- src/actions.c | 6 ++---- src/xinit.c | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/actions.c b/src/actions.c index 36e2fd39..90897ef0 100644 --- a/src/actions.c +++ b/src/actions.c @@ -3378,12 +3378,10 @@ void create_memory_cairo_ctx(int what) { #if HAS_CAIRO==1 static int created = 0; - enum { w = 100, h = 64, bpp = 4 }; - static unsigned char data[w * h * bpp]; + enum { w = 200, h = 150}; if(!created && what && !xctx->cairo_ctx) { - xctx->cairo_sfc = cairo_image_surface_create_for_data(data, - CAIRO_FORMAT_RGB24, w, h, bpp * w); + xctx->cairo_sfc = cairo_image_surface_create(CAIRO_FORMAT_RGB24, w, h); xctx->cairo_ctx = cairo_create(xctx->cairo_sfc); if(xctx->cairo_ctx) created = 1; } diff --git a/src/xinit.c b/src/xinit.c index a590fa49..086be67b 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -907,6 +907,7 @@ static void xwin_exit(void) } if(xctx->infowindow_text) my_free(_ALLOC_ID_, &xctx->infowindow_text); if(has_x) new_schematic("destroy_all", "1", NULL, 1); + else create_memory_cairo_ctx(0); /* clear in-memory created cairo_ctx if any */ drawbezier(xctx->window, xctx->gc[0], 0, NULL, NULL, 0, 0); delete_schematic_data(1); if(has_x) { @@ -925,8 +926,6 @@ static void xwin_exit(void) for(i = 0; i < cadlayers; ++i) Tk_FreePixmap(display, pixmap[i]); #endif my_free(_ALLOC_ID_, &pixmap); - } else { /* no X */ - create_memory_cairo_ctx(0); /* clear in-memory created cairo_ctx if any */ } dbg(1, "xwin_exit(): clearing drawing data structures\n");