[gnome-documents] utils: Simplify the clean-up



commit ca7d8d3436e436fca5ceb1e32d93789e424dfbb6
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Mar 31 20:16:05 2017 +0200

    utils: Simplify the clean-up
    
    It's more readable to unconditionally initialize everything that needs
    to be cleaned up, and do the clean up as part of the 'out' stanza. This
    is also how g_auto* works, so it brings us a step closer to it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=780780

 src/lib/gd-utils.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)
---
diff --git a/src/lib/gd-utils.c b/src/lib/gd-utils.c
index ba4f8a8..7606631 100644
--- a/src/lib/gd-utils.c
+++ b/src/lib/gd-utils.c
@@ -41,10 +41,10 @@ create_thumbnail (GIOSchedulerJob *job,
 {
   GSimpleAsyncResult *result = user_data;
   GFile *file = G_FILE (g_async_result_get_source_object (G_ASYNC_RESULT (result)));
-  GnomeDesktopThumbnailFactory *factory;
-  GFileInfo *info;
+  GnomeDesktopThumbnailFactory *factory = NULL;
+  GFileInfo *info = NULL;
   gchar *uri;
-  GdkPixbuf *pixbuf;
+  GdkPixbuf *pixbuf = NULL;
   guint64 mtime;
 
   uri = g_file_get_uri (file);
@@ -79,15 +79,14 @@ create_thumbnail (GIOSchedulerJob *job,
       g_simple_async_result_set_op_res_gboolean (result, FALSE);
     }
 
-  g_object_unref (info);
-  g_object_unref (file);
-  g_object_unref (factory);
-  g_clear_object (&pixbuf);
-
  out:
   g_simple_async_result_complete_in_idle (result);
   g_object_unref (result);
 
+  g_clear_object (&info);
+  g_object_unref (file);
+  g_clear_object (&factory);
+  g_clear_object (&pixbuf);
   return FALSE;
 }
 


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