From 54e6171e9c23fa5128f1319d5fefbf7ee5235d9a Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Thu, 13 Sep 2018 10:19:48 -0400 Subject: [PATCH] Corrected an error that prevents the compile option "--enable-cairo-offscreen" from working. Because the option does not run the full Cario initialization, the grTCairoVisualInfo is not set, and the first attempt to create a Cairo surface fails with a segfault. --- graphics/grTCairo1.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/graphics/grTCairo1.c b/graphics/grTCairo1.c index 871a94d4..ff9a50c8 100644 --- a/graphics/grTCairo1.c +++ b/graphics/grTCairo1.c @@ -363,6 +363,25 @@ int llx, lly, width, height; /* surface and context, so we need to make them. */ if (tcairodata == NULL) { + + /* For OpenGL using Cairo for off-screen rendering, */ + /* grTCairoVisualInfo may be NULL and need to be set. */ + if (grTCairoVisualInfo == NULL) + { + XVisualInfo grtemplate; + int gritems; + grtemplate.screen = grXscrn; + grtemplate.depth = 0; + grTCairoVisualInfo = XGetVisualInfo(grXdpy, VisualScreenMask, + &grtemplate, &gritems); + + if (!grTCairoVisualInfo) + { + TxError("No suitable visual!\n"); + return; + } + } + tcairodata = (TCairoData *)mallocMagic(sizeof(TCairoData)); tcairodata->surface = cairo_xlib_surface_create(grXdpy, tcairoCurrent.windowid, grTCairoVisualInfo->visual,