[Xfce4-commits] [xfce/tumbler] 02/02: On some systems $XDG_DATA_HOME can have duplicated path (ex. '/usr/share' twice). This causes tumbler to load a specilized thumbnailer twice causing an assertion failure in tumbler_manager_load_thumbnailer.

noreply at xfce.org noreply at xfce.org
Wed Jun 7 10:14:08 CEST 2017


This is an automated email from the git hooks/post-receive script.

a   l   i       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/tumbler.

commit 4aaa786f057d06bd7e84d746e4bd20cb7386ca21
Author: Ali Abdallah <ali at xfce.org>
Date:   Wed Jun 7 10:10:40 2017 +0200

    On some systems $XDG_DATA_HOME can have duplicated path
    (ex. '/usr/share' twice). This causes tumbler to load a
    specilized thumbnailer twice causing an assertion failure
    in tumbler_manager_load_thumbnailer.
    
    Use GHashTable to record already loaded path to avoid
    the issue, fix #13618.
---
 tumblerd/tumbler-manager.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/tumblerd/tumbler-manager.c b/tumblerd/tumbler-manager.c
index 9f837c2..49763fa 100644
--- a/tumblerd/tumbler-manager.c
+++ b/tumblerd/tumbler-manager.c
@@ -1238,6 +1238,7 @@ tumbler_manager_load_thumbnailers (TumblerManager *manager,
 void
 tumbler_manager_load (TumblerManager *manager)
 {
+  GHashTable         *single_path;
   const gchar *const *data_dirs;
   GFileMonitor       *monitor;
   GList              *directories = NULL;
@@ -1263,14 +1264,36 @@ tumbler_manager_load (TumblerManager *manager)
   /* determine system data dirs */
   data_dirs = g_get_system_data_dirs ();
 
+  /* Create a ghash table to insert loaded directory path to avoid duplication */
+  single_path = g_hash_table_new_full (g_file_hash, (GEqualFunc)g_file_equal, g_object_unref, NULL);
+
   /* build $XDG_DATA_DIRS/thumbnailers dirnames and prepend them to the list */
   for (n = 0; data_dirs[n] != NULL; ++n)
     {
-      dirname = g_build_filename (data_dirs[n], "thumbnailers", NULL);
-      directories = g_list_prepend (directories, g_file_new_for_path (dirname));
-      g_free (dirname);
+      GFile *path;
+
+      path = g_file_new_for_path(data_dirs[n]);
+
+      if (!g_hash_table_lookup (single_path, path))
+        {
+          /* Save it in the hash table so we can relocate it */
+          /* path will be free automatically by g_hash_table_destroy */
+          g_hash_table_insert (single_path, path, path);
+
+          dirname = g_build_filename (data_dirs[n], "thumbnailers", NULL);
+          directories = g_list_prepend (directories, g_file_new_for_path (dirname));
+          g_free (dirname);
+        }
+      else
+        {
+          /* Free the path GFile object */
+          g_object_unref(path);
+        }
     }
 
+  /* destroy the hash table used for loading single pathes */
+  g_hash_table_destroy (single_path);
+
   /* reverse the directory list so that the directories with highest 
    * priority come first */
   directories = g_list_reverse (directories);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list