From 3dae3205e7c80ed8524946dafe80896d24c6176a Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 13 Aug 2024 13:23:20 -0400 Subject: [PATCH] drawcontext: Fix up color state ownership begin_frame_full does not return a reference, we assume that the color state is staying alive for the duration of the frame anyway, so end_frame simply sets priv->color_state to NULL. --- gdk/gdkdrawcontext.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gdk/gdkdrawcontext.c b/gdk/gdkdrawcontext.c index 9a15f6947c..a440e19c8d 100644 --- a/gdk/gdkdrawcontext.c +++ b/gdk/gdkdrawcontext.c @@ -394,13 +394,15 @@ gdk_draw_context_begin_frame_full (GdkDrawContext *context, priv->frame_region = cairo_region_copy (region); priv->surface->paint_context = g_object_ref (context); + g_assert (priv->color_state == NULL); + GDK_DRAW_CONTEXT_GET_CLASS (context)->begin_frame (context, depth, priv->frame_region, &priv->color_state, &priv->depth); - /* the callback is meant to set them */ + /* The callback is meant to set them. Note that it does not return a ref */ g_assert (priv->color_state != NULL); g_assert (priv->depth < GDK_N_DEPTHS); @@ -439,7 +441,7 @@ gdk_draw_context_end_frame_full (GdkDrawContext *context) gdk_profiler_set_int_counter (pixels_counter, region_get_pixels (priv->frame_region)); - g_clear_pointer (&priv->color_state, gdk_color_state_unref); + priv->color_state = NULL; g_clear_pointer (&priv->frame_region, cairo_region_destroy); g_clear_object (&priv->surface->paint_context); priv->depth = GDK_N_DEPTHS;