[nautilus/wip/corey/fix-sort: 2/5] vfs-file: Handle setting metadata with a NULL list




commit 36c2632e99427a510a7933fdf7c2246224eadf47
Author: Corey Berla <corey berla me>
Date:   Tue Sep 27 15:20:49 2022 -0700

    vfs-file: Handle setting metadata with a NULL list
    
    Previous to 013edfaa7e567560baf2718ec75980b0118c93da, we had a special case
    for handling NULL values when calling nautilus_file_set_metadata_list,
    but after that commit, the NULL was passed directly to
    g_file_info_set_attribute_stringv() which is not allow.  This broke
    the "Reset to Default" button in the column chooser.
    
    g_file_info_remove_attribute() does not produce the expected behavior
    so simply set the attribute string to an empty string.

 src/nautilus-vfs-file.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/src/nautilus-vfs-file.c b/src/nautilus-vfs-file.c
index d9d288e43..54c9b65c7 100644
--- a/src/nautilus-vfs-file.c
+++ b/src/nautilus-vfs-file.c
@@ -203,7 +203,14 @@ vfs_file_set_metadata_as_list (NautilusFile  *file,
     info = g_file_info_new ();
 
     gio_key = g_strconcat ("metadata::", key, NULL);
-    g_file_info_set_attribute_stringv (info, gio_key, value);
+    if (value == NULL)
+    {
+        g_file_info_set_attribute_string (info, gio_key, "");
+    }
+    else
+    {
+        g_file_info_set_attribute_stringv (info, gio_key, value);
+    }
     g_free (gio_key);
 
     location = nautilus_file_get_location (file);


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