[nautilus] freedesktop-dbus: Use g_autoptr



commit 0c5948aa174168fdd3454c678663630be09d2f29
Author: Yi-Soo An <yisooan gmail com>
Date:   Thu Nov 22 12:29:03 2018 +0900

    freedesktop-dbus: Use g_autoptr
    
    Use g_autoptr instead of manually freeing resources.

 src/nautilus-freedesktop-dbus.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
---
diff --git a/src/nautilus-freedesktop-dbus.c b/src/nautilus-freedesktop-dbus.c
index 98b02d2de..5cbbbad01 100644
--- a/src/nautilus-freedesktop-dbus.c
+++ b/src/nautilus-freedesktop-dbus.c
@@ -63,8 +63,8 @@ skeleton_handle_show_items_cb (NautilusFreedesktopFileManager1 *object,
 
     for (i = 0; uris[i] != NULL; i++)
     {
-        GFile *file;
-        GFile *parent;
+        g_autoptr (GFile) file = NULL;
+        g_autoptr (GFile) parent = NULL;
 
         file = g_file_new_for_uri (uris[i]);
         parent = g_file_get_parent (file);
@@ -72,14 +72,11 @@ skeleton_handle_show_items_cb (NautilusFreedesktopFileManager1 *object,
         if (parent != NULL)
         {
             nautilus_application_open_location (application, parent, file, startup_id);
-            g_object_unref (parent);
         }
         else
         {
             nautilus_application_open_location (application, file, NULL, startup_id);
         }
-
-        g_object_unref (file);
     }
 
     nautilus_freedesktop_file_manager1_complete_show_items (object, invocation);
@@ -100,13 +97,11 @@ skeleton_handle_show_folders_cb (NautilusFreedesktopFileManager1 *object,
 
     for (i = 0; uris[i] != NULL; i++)
     {
-        GFile *file;
+        g_autoptr (GFile) file = NULL;
 
         file = g_file_new_for_uri (uris[i]);
 
         nautilus_application_open_location (application, file, NULL, startup_id);
-
-        g_object_unref (file);
     }
 
     nautilus_freedesktop_file_manager1_complete_show_folders (object, invocation);


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