[gvfs] gvfs-open: Fix incorrect use of g_app_info_launch_default_for_uri()



commit 95aac171c7b9903fefd7fa22888c32bb08d67132
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Oct 17 15:52:09 2014 +0200

    gvfs-open: Fix incorrect use of g_app_info_launch_default_for_uri()
    
    First, as we never check whether the passed arguments are indeed URIs,
    we'd be failing to work correctly for relative paths.
    Secondly, we would be running g_app_info_launch_default_for_uri() twice
    for no good reason.
    Finally, we were leaking the output of g_file_get_uri()
    
    https://bugzilla.gnome.org/show_bug.cgi?id=738690

 programs/gvfs-open.c |   21 ++++++++-------------
 1 files changed, 8 insertions(+), 13 deletions(-)
---
diff --git a/programs/gvfs-open.c b/programs/gvfs-open.c
index b98d6cf..81d7e2c 100644
--- a/programs/gvfs-open.c
+++ b/programs/gvfs-open.c
@@ -50,7 +50,6 @@ main (int argc, char *argv[])
   int i;
   gboolean success;
   gboolean res;
-  GFile *file;
 
   setlocale (LC_ALL, "");
 
@@ -104,20 +103,16 @@ main (int argc, char *argv[])
 
   do
     {
-      res = g_app_info_launch_default_for_uri (locations[i],
+      GFile *file;
+      char *uri;
+
+      file = g_file_new_for_commandline_arg (locations[i]);
+      uri = g_file_get_uri (file);
+      g_object_unref (file);
+      res = g_app_info_launch_default_for_uri (uri,
                                               NULL,
                                               &error);
-
-      if (!res && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED))
-       {
-         /* g_app_info_launch_default_for_uri() can't properly handle non-URI (local) locations */
-         g_clear_error (&error);
-         file = g_file_new_for_commandline_arg (locations[i]);
-         res = g_app_info_launch_default_for_uri (g_file_get_uri (file),
-                                                  NULL,
-                                                  &error);
-         g_object_unref (file);
-       }
+      g_free (uri);
 
       if (!res)
        {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]