From cd57d5729133e1d2f1987271f9437e72c626a93c Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Fri, 17 Apr 2020 17:44:42 +0200 Subject: [PATCH 1/5] open-uri: Return errors from launch_application_with_uri() --- src/open-uri.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/open-uri.c b/src/open-uri.c index c876ab6..c0dd94e 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, &error); + ruri = register_document (uri, choice_id, FALSE, writable, &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); } @@ -683,10 +685,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); -- 2.26.2