[nautilus] files-view: Autocleanup locals in set_wallpaper_fallback()



commit bf113781d0caa26db2b992f14e328e4cd7c038f4
Author: Barnabás Pőcze <pobrn protonmail com>
Date:   Thu Jul 1 16:19:08 2021 +0200

    files-view: Autocleanup locals in set_wallpaper_fallback()
    
    Instead of manually calling `g_object_unref()` and `g_free()`,
    use `g_auto{free,ptr}` to (mostly) do away with the need
    of manually managing the resources.

 src/nautilus-files-view.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 7e6dd8bd0..5f3e10d46 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -6854,19 +6854,17 @@ static void
 set_wallpaper_fallback (NautilusFile *file,
                         gpointer      user_data)
 {
-    char *target_uri;
+    g_autofree char *target_uri = NULL;
     GList *uris;
-    GFile *parent;
-    GFile *target;
+    g_autoptr (GFile) parent = NULL;
+    g_autoptr (GFile) target = NULL;
 
     /* Copy the item to Pictures/Wallpaper (internationalized) since it may be
      *  remote. Then set it as the current wallpaper. */
     parent = g_file_new_for_path (g_get_user_special_dir (G_USER_DIRECTORY_PICTURES));
     target = g_file_get_child (parent, _("Wallpapers"));
-    g_object_unref (parent);
     g_file_make_directory_with_parents (target, NULL, NULL);
     target_uri = g_file_get_uri (target);
-    g_object_unref (target);
     uris = g_list_prepend (NULL, nautilus_file_get_uri (file));
     nautilus_file_operations_copy_move (uris,
                                         target_uri,
@@ -6875,7 +6873,6 @@ set_wallpaper_fallback (NautilusFile *file,
                                         NULL,
                                         wallpaper_copy_done_callback,
                                         NULL);
-    g_free (target_uri);
     g_list_free_full (uris, g_free);
 }
 


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