[Xfce4-commits] [xfce/tumbler] 05/06: 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 12:03:33 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       x   f   c   e   -   4   .   1   2   
   in repository xfce/tumbler.

commit fa4e12c621040ba8660f58850588550ce237b0ff
Author: Ali Abdallah <ali at xfce.org>
Date:   Wed Jun 7 10:32:44 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 db5d64e..77cf8d0 100644
--- a/tumblerd/tumbler-manager.c
+++ b/tumblerd/tumbler-manager.c
@@ -1179,6 +1179,7 @@ tumbler_manager_load_thumbnailers (TumblerManager *manager,
 static void
 tumbler_manager_load (TumblerManager *manager)
 {
+  GHashTable         *single_path;
   const gchar *const *data_dirs;
   GFileMonitor       *monitor;
   GList              *directories = NULL;
@@ -1204,14 +1205,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