[neon/backports-focal/xdg-desktop-portal/Neon/unstable] src: open-uri: Return errors from launch_application_with_uri()

Bastien Nocera null at kde.org
Wed Jan 13 06:32:42 GMT 2021


Git commit 56d94fe99fc73ea681becb0b959e31e2be5f9db8 by Bastien Nocera.
Committed on 17/04/2020 at 15:46.
Pushed by ash into branch 'Neon/unstable'.

open-uri: Return errors from launch_application_with_uri()

M  +10   -7    src/open-uri.c

https://invent.kde.org/neon/backports-focal/xdg-desktop-portal/commit/56d94fe99fc73ea681becb0b959e31e2be5f9db8

diff --git a/src/open-uri.c b/src/open-uri.c
index 57214db..a8326ed 100644
--- a/src/open-uri.c
+++ b/src/open-uri.c
@@ -226,7 +226,8 @@ static gboolean
 launch_application_with_uri (const char *choice_id,
                              const char *uri,
                              const char *parent_window,
-                             gboolean writable)
+                             gboolean    writable,
+                             GError    **error)
 {
   g_autofree char *desktop_id = g_strconcat (choice_id, ".desktop", NULL);
   g_autoptr(GDesktopAppInfo) info = g_desktop_app_info_new (desktop_id);
@@ -238,14 +239,15 @@ launch_application_with_uri (const char *choice_id,
 
   if (is_sandboxed (info) && is_file_uri (uri))
     {
-      g_autoptr(GError) error = NULL;
+      g_autoptr(GError) local_error = NULL;
 
       g_debug ("Registering %s for %s", uri, choice_id);
 
-      ruri = register_document (uri, choice_id, FALSE, writable, FALSE, &error);
+      ruri = register_document (uri, choice_id, FALSE, writable, FALSE, &local_error);
       if (ruri == NULL)
         {
-          g_warning ("Error registering %s for %s: %s", uri, choice_id, error->message);
+          g_warning ("Error registering %s for %s: %s", uri, choice_id, local_error->message);
+          g_propagate_error (error, local_error);
           return FALSE;
         }
     }
@@ -257,7 +259,7 @@ launch_application_with_uri (const char *choice_id,
   uris.data = (gpointer)ruri;
   uris.next = NULL;
 
-  g_app_info_launch_uris (G_APP_INFO (info), &uris, context, NULL);
+  g_app_info_launch_uris (G_APP_INFO (info), &uris, context, error);
 
   return TRUE;
 }
@@ -354,7 +356,7 @@ send_response_in_thread_func (GTask *task,
       writable = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (request), "writable"));
       content_type = (const char *)g_object_get_data (G_OBJECT (request), "content-type");
 
-      if (launch_application_with_uri (choice, uri, parent_window, writable))
+      if (launch_application_with_uri (choice, uri, parent_window, writable, NULL))
         update_permissions_store (xdp_app_info_get_id (request->app_info), content_type, choice);
     }
 
@@ -691,10 +693,11 @@ handle_open_in_thread_func (GTask *task,
       if (app)
         {
           /* Launch the app directly */
+          g_autoptr(GError) error = NULL;
 
           g_debug ("Skipping app chooser");
 
-          gboolean result = launch_application_with_uri (app, uri, parent_window, writable);
+          gboolean result = launch_application_with_uri (app, uri, parent_window, writable, &error);
           if (request->exported)
             {
               g_variant_builder_init (&opts_builder, G_VARIANT_TYPE_VARDICT);



More information about the Neon-commits mailing list