[gnome-shell/gbsneto/clutter-image-on-texture-cache: 3/3] texture-cache: Simplify function with g_autoptr



commit 3dcb593a71e30cec15e50937edbe9fc8672c9df1
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Jan 24 16:02:30 2019 -0200

    texture-cache: Simplify function with g_autoptr
    
    st_texture_cache_reset_texture() is slightly easier to
    read and follow by using g_autoptr, so use that.

 src/st/st-texture-cache.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
---
diff --git a/src/st/st-texture-cache.c b/src/st/st-texture-cache.c
index d0c49960b..ad177b35e 100644
--- a/src/st/st-texture-cache.c
+++ b/src/st/st-texture-cache.c
@@ -658,8 +658,8 @@ st_texture_cache_reset_texture (StTextureCachePropertyBind *bind,
       (cairo_image_surface_get_format (surface) == CAIRO_FORMAT_ARGB32 ||
        cairo_image_surface_get_format (surface) == CAIRO_FORMAT_RGB24))
     {
-      ClutterContent *image;
-      GError *error = NULL;
+      g_autoptr(ClutterContent) image = NULL;
+      g_autoptr(GError) error = NULL;
 
       image = clutter_actor_get_content (bind->actor);
       if (!image || !CLUTTER_IS_IMAGE (image))
@@ -677,15 +677,9 @@ st_texture_cache_reset_texture (StTextureCachePropertyBind *bind,
                               &error);
 
       if (image)
-        {
-          clutter_actor_set_content (bind->actor, image);
-          g_object_unref (image);
-        }
+        clutter_actor_set_content (bind->actor, image);
       else if (error)
-        {
-          g_warning ("Failed to allocate texture: %s", error->message);
-          g_error_free (error);
-        }
+        g_warning ("Failed to allocate texture: %s", error->message);
 
       clutter_actor_set_opacity (bind->actor, 255);
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]