[Xfce4-commits] <thunar:xfce-4.8> Fix handling %U when launching multiple files with an app (bug #7456).

Jannis Pohlmann noreply at xfce.org
Sun Feb 26 20:00:01 CET 2012


Updating branch refs/heads/xfce-4.8
         to 379b8b9f350cb362735eb0e2a0e9471a898f2664 (commit)
       from 71f6f207cfd0194a3f3db83cb5fab694a5036e22 (commit)

commit 379b8b9f350cb362735eb0e2a0e9471a898f2664
Author: John Lindgren <john.lindgren at aol.com>
Date:   Sun Feb 26 18:52:24 2012 +0000

    Fix handling %U when launching multiple files with an app (bug #7456).
    
    GIO returns a newly allocated GAppInfo every time
    g_app_info_get_default_for_type() is called. This means that if we use a
    GHashTable and g_direct_hash() to associate GAppInfos with files to be
    launched with each of them, we will actually end up with multiple
    GAppInfos that are the same, and each of them will only have a single
    file associated.
    
    To fix this, we now use a fake hash function that causes GHashTable to
    always search the GAppInfo in the collision list.

 NEWS                     |    1 +
 thunar/thunar-launcher.c |   17 ++++++++++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index f91553e..eb1d02e 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@
 - Fix sorting of filenames with large numbers (bug #5356).
   Patch by Erik Koegel.
 - Fix crash when removing an ancestor of the current folder (bug #8168).
+- Fix handling %U when launching multiple files with an app (bug #7456).
 
 1.2.3
 =====
diff --git a/thunar/thunar-launcher.c b/thunar/thunar-launcher.c
index f479cf9..9f96b87 100644
--- a/thunar/thunar-launcher.c
+++ b/thunar/thunar-launcher.c
@@ -546,17 +546,28 @@ thunar_launcher_execute_files (ThunarLauncher *launcher,
 
 
 
+static guint
+thunar_launcher_g_app_info_hash (gconstpointer app_info)
+{
+  return 0;
+}
+
+
+
 static void
 thunar_launcher_open_files (ThunarLauncher *launcher,
                             GList          *files)
 {
-  GAppInfo   *app_info;
   GHashTable *applications;
+  GAppInfo   *app_info;
   GList      *file_list;
   GList      *lp;
 
-  /* allocate a hash table to associate applications to URIs */
-  applications = g_hash_table_new_full (g_direct_hash,
+  /* allocate a hash table to associate applications to URIs. since GIO allocates
+   * new GAppInfo objects every time, g_direct_hash does not work. we therefor use
+   * a fake hash function to always hit the collision list of the hash table and
+   * avoid storing multiple equal GAppInfos by means of g_app_info_equal(). */
+  applications = g_hash_table_new_full (thunar_launcher_g_app_info_hash,
                                         (GEqualFunc) g_app_info_equal,
                                         (GDestroyNotify) g_object_unref,
                                         (GDestroyNotify) thunar_g_file_list_free);


More information about the Xfce4-commits mailing list