summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli Abdallah <ali@xfce.org>2017-06-07 10:10:40 +0200
committerAli Abdallah <ali@xfce.org>2017-06-07 10:10:40 +0200
commit4aaa786f057d06bd7e84d746e4bd20cb7386ca21 (patch)
tree5f2e4fab17d2bbc3758f86024821e104794d2a26
parent984e67ce5247a2543f0fd547b42201043c69e9b2 (diff)
downloadtumbler-4aaa786f057d06bd7e84d746e4bd20cb7386ca21.tar.gz
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.
-rw-r--r--tumblerd/tumbler-manager.c29
1 files 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);