[gtk+/portal] Be a bit more careful



commit 123c59c3b08f6dafab2226f649f91585dce10eef
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Jun 28 19:31:39 2016 -0400

    Be a bit more careful
    
    If we don't get choices back from the portal, don't crash.

 gtk/gtkfilechoosernativeportal.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkfilechoosernativeportal.c b/gtk/gtkfilechoosernativeportal.c
index 29ce73c..462eedf 100644
--- a/gtk/gtkfilechoosernativeportal.c
+++ b/gtk/gtkfilechoosernativeportal.c
@@ -108,13 +108,14 @@ response_cb (GDBusConnection  *connection,
   g_variant_lookup (response_data, "uris", "^a&s", &uris);
 
   choices = g_variant_lookup_value (response_data, "choices", G_VARIANT_TYPE ("a(ss)"));
-  for (i = 0; i < g_variant_n_children (choices); i++)
-    {
-      const char *id;
-      const char *selected;
-      g_variant_get_child (choices, i, "(&s&s)", &id, &selected);
-      gtk_file_chooser_native_set_choice (self, id, selected);
-    }
+  if (choices)
+    for (i = 0; i < g_variant_n_children (choices); i++)
+      {
+        const char *id;
+        const char *selected;
+        g_variant_get_child (choices, i, "(&s&s)", &id, &selected);
+        gtk_file_chooser_native_set_choice (self, id, selected);
+      }
 
   g_slist_free_full (self->custom_files, g_object_unref);
   self->custom_files = NULL;


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