From fd6c1f34da3a7a7282a20cb802331badc245005d Mon Sep 17 00:00:00 2001 From: Arjan Molenaar Date: Fri, 27 Sep 2024 19:08:01 +0200 Subject: [PATCH] macos: Fix URL launcher URLs should be provided to the AppInfo.launch_uris() function. --- gio/gosxappinfo.m | 2 -- gio/tests/osx-appinfo.c | 25 ++++++++++++++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/gio/gosxappinfo.m b/gio/gosxappinfo.m index cc20a41d2..038429456 100644 --- a/gio/gosxappinfo.m +++ b/gio/gosxappinfo.m @@ -456,8 +456,6 @@ g_osx_app_info_launch_internal (GAppInfo *appinfo, gint ret, success = TRUE; g_return_val_if_fail (G_IS_OSX_APP_INFO (appinfo), FALSE); - g_return_val_if_fail (uris == NULL, FALSE); - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); fill_urlspec_for_appinfo (&urlspec, info, uris, are_files); diff --git a/gio/tests/osx-appinfo.c b/gio/tests/osx-appinfo.c index eca18bd8c..e7dd9d75a 100644 --- a/gio/tests/osx-appinfo.c +++ b/gio/tests/osx-appinfo.c @@ -35,7 +35,7 @@ async_result_cb (GObject *source_object, } static void -test_launch_async (void) +test_launch_async (GList *uris) { GAppInfo *app_info; GAppLaunchContext *context; @@ -48,7 +48,7 @@ test_launch_async (void) context = g_app_launch_context_new (); - g_app_info_launch_uris_async (G_APP_INFO (app_info), NULL, context, NULL, async_result_cb, &result); + g_app_info_launch_uris_async (G_APP_INFO (app_info), uris, context, NULL, async_result_cb, &result); while (result == NULL) g_main_context_iteration (NULL, TRUE); @@ -65,6 +65,24 @@ test_launch_async (void) g_clear_object (&app_info); } + +static void +test_launch_async_with_uris (void) +{ + GList *uris; + uris = g_list_prepend (NULL, "file:///hopefully/an/invalid/path.txt"); + + test_launch_async (uris); + + g_list_free (uris); +} + +static void +test_launch_async_without_uris (void) +{ + test_launch_async (NULL); +} + static void test_invalid_uri_scheme (void) { @@ -80,7 +98,8 @@ main (int argc, { g_test_init (&argc, &argv, NULL, NULL); - g_test_add_func ("/osx-app-info/launch-async", test_launch_async); + g_test_add_func ("/osx-app-info/launch-async-with-uris", test_launch_async_with_uris); + g_test_add_func ("/osx-app-info/launch-async-without-uris", test_launch_async_without_uris); g_test_add_func ("/osx-app-info/invalid-uri-scheme", test_invalid_uri_scheme); return g_test_run ();