replace cairo_image_surface_create_for_data with cairo_image_surface_create in create_memory_cairo_ctx

This commit is contained in:
stefan schippers 2024-03-12 12:03:53 +01:00
parent 9b8015b437
commit e4ef7d4dc1
2 changed files with 3 additions and 6 deletions

View File

@ -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;
}

View File

@ -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");