[recipes/fix-help-crash: 3/3] app: Don't crash if no help handler is registered



commit 2c0f0c5eaeb911f5e531c1d7d4a9812727f29e5e
Author: Matthew Leeds <matthew leeds endlessm com>
Date:   Fri Feb 14 22:26:32 2020 -0800

    app: Don't crash if no help handler is registered
    
    g_app_info_get_default_for_uri_scheme() is documented to return NULL on
    error, so handle that case.
    
    Fixes https://gitlab.gnome.org/GNOME/recipes/issues/99

 src/gr-app.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/src/gr-app.c b/src/gr-app.c
index 830b7eb..140e359 100644
--- a/src/gr-app.c
+++ b/src/gr-app.c
@@ -262,7 +262,9 @@ help_activated (GSimpleAction *action,
         g_autoptr(GError) error = NULL;
 
         info = g_app_info_get_default_for_uri_scheme ("help");
-        if (!g_app_info_launch_uris (info, &uris, NULL, &error))
+        if (info == NULL)
+                g_warning ("Failed to get a launcher for the URI scheme 'help:'");
+        else if (!g_app_info_launch_uris (info, &uris, NULL, &error))
                 g_warning ("Failed to launch %s: %s", g_app_info_get_name (info), error->message);
 }
 


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