[gtk+] testappchooser: handle 'no app selected' gracefully



commit 3fa5813ea386e83859834f214b840bfee8f33d1d
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Aug 28 23:50:50 2011 -0400

    testappchooser: handle 'no app selected' gracefully
    
    The test was assuming that it always gets an app info back,
    when in reality it might get NULL back.

 tests/testappchooser.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/tests/testappchooser.c b/tests/testappchooser.c
index 6bf121a..dd40ed6 100644
--- a/tests/testappchooser.c
+++ b/tests/testappchooser.c
@@ -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));



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