diff options
author | Benjamin Otte <otte@redhat.com> | 2019-06-03 17:20:59 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2019-06-03 17:22:11 +0200 |
commit | d81cf5a44345cc8a8d3bd53501dbb24f96d17a21 (patch) | |
tree | 79f9d6ca05621bed088e097d47e68c814d18bfd4 /gsk/gskrendernodeparser.c | |
parent | 22e078580278c5403c80f9ed6b25de2d891cde5c (diff) | |
download | gtk+-d81cf5a44345cc8a8d3bd53501dbb24f96d17a21.tar.gz |
rendernodeparser: Handle Cairo being stupid
Cairo writes to finished streams, so we have to make sure to keep the
stream around to allow it to do that.
Diffstat (limited to 'gsk/gskrendernodeparser.c')
-rw-r--r-- | gsk/gskrendernodeparser.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/gsk/gskrendernodeparser.c b/gsk/gskrendernodeparser.c index 4cdf70f630..2b35dc7cb2 100644 --- a/gsk/gskrendernodeparser.c +++ b/gsk/gskrendernodeparser.c @@ -1903,6 +1903,12 @@ cairo_write_array (void *closure, } static void +cairo_destroy_array (gpointer array) +{ + g_byte_array_free (array, TRUE); +} + +static void render_node_print (Printer *p, GskRenderNode *node) { @@ -2394,6 +2400,7 @@ render_node_print (Printer *p, #ifdef CAIRO_HAS_SCRIPT_SURFACE if (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_RECORDING) { + static const cairo_user_data_key_t cairo_is_stupid_key; cairo_device_t *script; array = g_byte_array_new (); @@ -2407,11 +2414,17 @@ render_node_print (Printer *p, g_free (b64); } - cairo_device_destroy (script); - g_byte_array_free (array, TRUE); - } + /* because Cairo is stupid and writes to the device after we finished it, + * we can't just + g_byte_array_free (array, TRUE); + * but have to + */ + g_byte_array_set_size (array, 0); + cairo_device_set_user_data (script, &cairo_is_stupid_key, array, cairo_destroy_array); + cairo_device_destroy (script); + } #endif - } + } end_node (p); } |