[nautilus/recent-manager-update: 1/5] file: Use g_autofree and g_autoptr in info lookup



commit 4997c1465194714302ff32dda2c7ee8eae98e5fc
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Wed Apr 11 23:51:34 2018 +0100

    file: Use g_autofree and g_autoptr in info lookup

 src/nautilus-file.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)
---
diff --git a/src/nautilus-file.c b/src/nautilus-file.c
index b9ae81e08..6b92ec705 100644
--- a/src/nautilus-file.c
+++ b/src/nautilus-file.c
@@ -1846,14 +1846,12 @@ rename_get_info_callback (GObject      *source_object,
                           GAsyncResult *res,
                           gpointer      callback_data)
 {
+    g_autoptr (GFileInfo) new_info = NULL;
+    g_autoptr (GError) error = NULL;
     NautilusFileOperation *op;
     NautilusDirectory *directory;
     NautilusFile *existing_file;
-    char *old_uri;
-    char *new_uri;
     const char *new_name;
-    GFileInfo *new_info;
-    GError *error;
 
     op = callback_data;
 
@@ -1861,8 +1859,10 @@ rename_get_info_callback (GObject      *source_object,
     new_info = g_file_query_info_finish (G_FILE (source_object), res, &error);
     if (new_info != NULL)
     {
-        directory = op->file->details->directory;
+        g_autofree char *old_uri = NULL;
+        g_autofree char *new_uri = NULL;
 
+        directory = op->file->details->directory;
         new_name = g_file_info_get_name (new_info);
 
         /* If there was another file by the same name in this
@@ -1882,16 +1882,8 @@ rename_get_info_callback (GObject      *source_object,
 
         new_uri = nautilus_file_get_uri (op->file);
         nautilus_directory_moved (old_uri, new_uri);
-        g_free (new_uri);
-        g_free (old_uri);
-
-        g_object_unref (new_info);
     }
     nautilus_file_operation_complete (op, NULL, error);
-    if (error)
-    {
-        g_error_free (error);
-    }
 }
 
 static void


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