[Xfce4-commits] [xfce/tumbler] 01/01: Avoid loading desktop thumbnailers twice when XDG_DATA_DIRS has path duplications.
noreply at xfce.org
noreply at xfce.org
Wed Jun 7 11:34:23 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 a99347e03be2b075fceab33a068640e7f68767c0
Author: Ali Abdallah <ali at xfce.org>
Date: Wed Jun 7 11:33:54 2017 +0200
Avoid loading desktop thumbnailers twice when XDG_DATA_DIRS
has path duplications.
---
.../desktop-thumbnailer-provider.c | 24 +++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/plugins/desktop-thumbnailer/desktop-thumbnailer-provider.c b/plugins/desktop-thumbnailer/desktop-thumbnailer-provider.c
index 8a452c4..e1455e7 100644
--- a/plugins/desktop-thumbnailer/desktop-thumbnailer-provider.c
+++ b/plugins/desktop-thumbnailer/desktop-thumbnailer-provider.c
@@ -221,6 +221,7 @@ desktop_thumbnailer_get_thumbnailers_from_dir (GList *thumbnailers,
static GList *
desktop_thumbnailer_provider_get_thumbnailers (TumblerThumbnailerProvider *provider)
{
+ GHashTable *single_path;
const gchar *const *data_dirs;
gchar *dirname;
GStrv uri_schemes;
@@ -234,12 +235,29 @@ desktop_thumbnailer_provider_get_thumbnailers (TumblerThumbnailerProvider *provi
/* build $XDG_DATA_DIRS/thumbnailers dirnames and prepend them to the list */
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);
+
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))
+ {
+ 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 */
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list