]> Pileus Git - ~andy/gtk/commitdiff
testappchooser: handle 'no app selected' gracefully
authorMatthias Clasen <mclasen@redhat.com>
Mon, 29 Aug 2011 03:50:50 +0000 (23:50 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 29 Aug 2011 03:50:50 +0000 (23:50 -0400)
The test was assuming that it always gets an app info back,
when in reality it might get NULL back.

tests/testappchooser.c

index 6bf121a68577ce340ed8844abf8f1e8077c5bc15..dd40ed6b874acb8aff2c6ce4477ce2d674f884a6 100644 (file)
@@ -41,10 +41,14 @@ dialog_response (GtkDialog *d,
   if (response_id == GTK_RESPONSE_OK)
     {
       app_info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (d));
-      name = g_app_info_get_name (app_info);
-      g_print ("Application selected: %s\n", name);
-
-      g_object_unref (app_info);
+      if (app_info)
+        {
+          name = g_app_info_get_name (app_info);
+          g_print ("Application selected: %s\n", name);
+          g_object_unref (app_info);
+        }
+      else
+        g_print ("No application selected\n");
     }
 
   gtk_widget_destroy (GTK_WIDGET (d));