diff --git a/gtk/gtkhsv.c b/gtk/gtkhsv.c index 2bee85844..ab910896e 100644 --- a/gtk/gtkhsv.c +++ b/gtk/gtkhsv.c @@ -873,6 +873,8 @@ gtk_hsv_motion (GtkWidget *widget, /* Redrawing */ /* Paints the hue ring */ +static const cairo_user_data_key_t pixels_key; + static void paint_ring (GtkHSV *hsv, cairo_t *cr, @@ -953,6 +955,9 @@ paint_ring (GtkHSV *hsv, source = cairo_image_surface_create_for_data ((unsigned char *)buf, CAIRO_FORMAT_RGB24, width, height, stride); + /* the pixels live as long as the surface: cairo may still use them + * after the drawing here, as cairo-quartz does (Ardour found it) */ + cairo_surface_set_user_data (source, &pixels_key, buf, g_free); /* Now draw the value marker onto the source image, so that it * will get properly clipped at the edges of the ring @@ -992,8 +997,6 @@ paint_ring (GtkHSV *hsv, cairo_stroke (cr); cairo_restore (cr); - - g_free (buf); } /* Converts an HSV triplet to an integer RGB triplet */ @@ -1165,6 +1168,9 @@ paint_triangle (GtkHSV *hsv, source = cairo_image_surface_create_for_data ((unsigned char *)buf, CAIRO_FORMAT_RGB24, width, height, stride); + /* the pixels live as long as the surface: cairo may still use them + * after the drawing here, as cairo-quartz does (Ardour found it) */ + cairo_surface_set_user_data (source, &pixels_key, buf, g_free); /* Draw a triangle with the image as a source */ @@ -1177,8 +1183,6 @@ paint_triangle (GtkHSV *hsv, cairo_close_path (cr); cairo_fill (cr); - g_free (buf); - /* Draw value marker */ xx = floor (sx + (vx - sx) * priv->v + (hx - vx) * priv->s * priv->v + 0.5);