[gnome-software/gnome-3-16] details: Don't crash when launching an app that has no desktop ID



commit 62899b759c375867b2aa4ee1667d6d862b5fd842
Author: Kalev Lember <kalevlember gmail com>
Date:   Mon Jun 15 13:29:35 2015 +0200

    details: Don't crash when launching an app that has no desktop ID
    
    Be more defensive and avoid crashing when dealing with apps that have no
    desktop ID associated. First, we make sure to hide the Launch button;
    and second, just to be double sure, also check that the app ID is there
    in the button's callback handler as well.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1231697

 src/gs-shell-details.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 43eddaf..1fe0dc0 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -689,6 +689,11 @@ gs_shell_details_refresh_all (GsShellDetails *shell_details)
                break;
        }
 
+       /* don't show the launch button if the app doesn't have a desktop ID */
+       tmp = gs_app_get_id (priv->app);
+       if (tmp == NULL)
+               gtk_widget_set_visible (priv->button_details_launch, FALSE);
+
        /* make history button insensitive if there is none */
        history = gs_app_get_history (priv->app);
        switch (gs_app_get_id_kind (priv->app)) {
@@ -1098,12 +1103,16 @@ gs_shell_details_app_launch_button_cb (GtkWidget *widget, GsShellDetails *shell_
        _cleanup_object_unref_ GAppLaunchContext *context = NULL;
 
        desktop_id = gs_app_get_id (shell_details->priv->app);
-       display = gdk_display_get_default ();
+       if (desktop_id == NULL) {
+               g_warning ("no such desktop file: %s", desktop_id);
+               return;
+       }
        appinfo = G_APP_INFO (g_desktop_app_info_new (desktop_id));
        if (appinfo == NULL) {
                g_warning ("no such desktop file: %s", desktop_id);
                return;
        }
+       display = gdk_display_get_default ();
        context = G_APP_LAUNCH_CONTEXT (gdk_display_get_app_launch_context (display));
        if (!g_app_info_launch (appinfo, NULL, context, &error))
                g_warning ("launching %s failed: %s", desktop_id, error->message);


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