[glib/wip/pwithnall/2119-osx-app-info: 3/3] gosxappinfo: Add some more precondition checks
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/pwithnall/2119-osx-app-info: 3/3] gosxappinfo: Add some more precondition checks
- Date: Wed, 9 Dec 2020 11:45:33 +0000 (UTC)
commit a9fc7e59357233771f1b137b6ebec382371b6e54
Author: Philip Withnall <pwithnall endlessos org>
Date: Wed Dec 9 11:44:37 2020 +0000
gosxappinfo: Add some more precondition checks
These might help catch the problem in #2119 earlier on, and provide more
information about its root cause.
They should not affect behaviour in normal application usage.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #2119
gio/gosxappinfo.m | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/gio/gosxappinfo.m b/gio/gosxappinfo.m
index bcb1f5648..03c373778 100644
--- a/gio/gosxappinfo.m
+++ b/gio/gosxappinfo.m
@@ -168,6 +168,7 @@ get_bundle_string_value (NSBundle *bundle,
static CFStringRef
create_cfstring_from_cstr (const gchar *cstr)
{
+ g_return_val_if_fail (cstr != NULL, NULL);
return CFStringCreateWithCString (NULL, cstr, kCFStringEncodingUTF8);
}
@@ -279,8 +280,14 @@ create_urlspec_for_appinfo (GOsxAppInfo *info,
GList *uris,
gboolean are_files)
{
- LSLaunchURLSpec *urlspec = g_new0 (LSLaunchURLSpec, 1);
- const gchar *app_cstr = g_osx_app_info_get_filename (info);
+ LSLaunchURLSpec *urlspec = NULL;
+ const gchar *app_cstr;
+
+ g_return_val_if_fail (G_IS_OSX_APP_INFO (info), NULL);
+
+ urlspec = g_new0 (LSLaunchURLSpec, 1);
+ app_cstr = g_osx_app_info_get_filename (info);
+ g_assert (app_cstr != NULL);
/* Strip file:// from app url but ensure filesystem url */
urlspec->appURL = create_url_from_cstr (app_cstr + strlen ("file://"), TRUE);
@@ -460,9 +467,14 @@ g_osx_app_info_launch_internal (GAppInfo *appinfo,
GError **error)
{
GOsxAppInfo *info = G_OSX_APP_INFO (appinfo);
- LSLaunchURLSpec *urlspec = create_urlspec_for_appinfo (info, uris, are_files);
+ LSLaunchURLSpec *urlspec;
gint ret, success = TRUE;
+ g_return_val_if_fail (G_IS_OSX_APP_INFO (appinfo), FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ urlspec = create_urlspec_for_appinfo (info, uris, are_files);
+
if ((ret = LSOpenFromURLSpec (urlspec, NULL)))
{
/* TODO: Better error codes */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]