Blame SOURCES/0006-clutter-backend-Use-an-auto-pointer-to-handle-the-te.patch

79df40
From bfd1c16e87cf9f90e8fe039b4bab400c68fb68a2 Mon Sep 17 00:00:00 2001
79df40
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
79df40
Date: Wed, 24 Jul 2019 16:49:38 +0200
79df40
Subject: [PATCH 06/28] clutter/backend: Use an auto-pointer to handle the
79df40
 template on creation
79df40
79df40
We allocate a CoglOnscreenTemplate but this is not unreffed if we have an error,
79df40
so let's just use an auto-pointer to manage its lifecycle.
79df40
79df40
https://gitlab.gnome.org/GNOME/mutter/merge_requests/682
79df40
---
79df40
 clutter/clutter/clutter-backend.c | 6 ++----
79df40
 1 file changed, 2 insertions(+), 4 deletions(-)
79df40
79df40
diff --git a/clutter/clutter/clutter-backend.c b/clutter/clutter/clutter-backend.c
79df40
index 30ebe5ef1..69aeec5eb 100644
79df40
--- a/clutter/clutter/clutter-backend.c
79df40
+++ b/clutter/clutter/clutter-backend.c
79df40
@@ -234,81 +234,79 @@ clutter_backend_do_real_create_context (ClutterBackend  *backend,
79df40
 
79df40
   klass = CLUTTER_BACKEND_GET_CLASS (backend);
79df40
 
79df40
   swap_chain = NULL;
79df40
   internal_error = NULL;
79df40
 
79df40
   CLUTTER_NOTE (BACKEND, "Creating Cogl renderer");
79df40
   backend->cogl_renderer = klass->get_renderer (backend, &internal_error);
79df40
 
79df40
   if (backend->cogl_renderer == NULL)
79df40
     goto error;
79df40
 
79df40
   CLUTTER_NOTE (BACKEND, "Connecting the renderer");
79df40
   cogl_renderer_set_driver (backend->cogl_renderer, driver_id);
79df40
   if (!cogl_renderer_connect (backend->cogl_renderer, &internal_error))
79df40
     goto error;
79df40
 
79df40
   CLUTTER_NOTE (BACKEND, "Creating Cogl swap chain");
79df40
   swap_chain = cogl_swap_chain_new ();
79df40
 
79df40
   CLUTTER_NOTE (BACKEND, "Creating Cogl display");
79df40
   if (klass->get_display != NULL)
79df40
     {
79df40
       backend->cogl_display = klass->get_display (backend,
79df40
                                                   backend->cogl_renderer,
79df40
                                                   swap_chain,
79df40
                                                   &internal_error);
79df40
     }
79df40
   else
79df40
     {
79df40
-      CoglOnscreenTemplate *tmpl;
79df40
+      g_autoptr (CoglOnscreenTemplate) tmpl = NULL;
79df40
       gboolean res;
79df40
 
79df40
       tmpl = cogl_onscreen_template_new (swap_chain);
79df40
 
79df40
       /* XXX: I have some doubts that this is a good design.
79df40
        *
79df40
        * Conceptually should we be able to check an onscreen_template
79df40
        * without more details about the CoglDisplay configuration?
79df40
        */
79df40
       res = cogl_renderer_check_onscreen_template (backend->cogl_renderer,
79df40
                                                    tmpl,
79df40
                                                    &internal_error);
79df40
 
79df40
       if (!res)
79df40
         goto error;
79df40
 
79df40
-      backend->cogl_display = cogl_display_new (backend->cogl_renderer, tmpl);
79df40
-
79df40
       /* the display owns the template */
79df40
-      cogl_object_unref (tmpl);
79df40
+      backend->cogl_display = cogl_display_new (backend->cogl_renderer, tmpl);
79df40
     }
79df40
 
79df40
   if (backend->cogl_display == NULL)
79df40
     goto error;
79df40
 
79df40
 #ifdef CLUTTER_HAS_WAYLAND_COMPOSITOR_SUPPORT
79df40
   cogl_wayland_display_set_compositor_display (backend->cogl_display,
79df40
                                                _wayland_compositor_display);
79df40
 #endif
79df40
 
79df40
   CLUTTER_NOTE (BACKEND, "Setting up the display");
79df40
   if (!cogl_display_setup (backend->cogl_display, &internal_error))
79df40
     goto error;
79df40
 
79df40
   CLUTTER_NOTE (BACKEND, "Creating the Cogl context");
79df40
   backend->cogl_context = cogl_context_new (backend->cogl_display, &internal_error);
79df40
   if (backend->cogl_context == NULL)
79df40
     goto error;
79df40
 
79df40
   /* the display owns the renderer and the swap chain */
79df40
   cogl_object_unref (backend->cogl_renderer);
79df40
   cogl_object_unref (swap_chain);
79df40
 
79df40
   return TRUE;
79df40
 
79df40
 error:
79df40
   if (backend->cogl_display != NULL)
79df40
     {
79df40
       cogl_object_unref (backend->cogl_display);
79df40
       backend->cogl_display = NULL;
79df40
-- 
79df40
2.26.2
79df40