[gedit/dbus] Fixed parsing file list from gvariant in open method



commit 3151d517e0383849df63fb6bc4f3294b1bbf8888
Author: Jesse van den Kieboom <jessevdk gnome org>
Date:   Mon May 3 00:40:32 2010 +0200

    Fixed parsing file list from gvariant in open method

 gedit/gedit-dbus.c |   17 ++++++-----------
 1 files changed, 6 insertions(+), 11 deletions(-)
---
diff --git a/gedit/gedit-dbus.c b/gedit/gedit-dbus.c
index 98b1249..4a10310 100644
--- a/gedit/gedit-dbus.c
+++ b/gedit/gedit-dbus.c
@@ -420,19 +420,14 @@ handle_service (GeditDBus *dbus)
 }
 
 static GSList *
-variant_file_list_to_locations (GVariant *file_list)
+variant_iter_list_to_locations (GVariantIter *iter)
 {
+	gchar *uri;
 	GSList *ret = NULL;
-	gsize num = g_variant_n_children (file_list);
-	gsize i;
 
-	for (i = 0; i < num; ++i)
+	while (g_variant_iter_loop (iter, "s", &uri))
 	{
-		gchar *uri;
-		g_variant_get_child (file_list, i, "s", &uri);
-
 		ret = g_slist_prepend (ret, g_file_new_for_uri (uri));
-		g_free (uri);
 	}
 
 	return g_slist_reverse (ret);
@@ -637,7 +632,7 @@ dbus_handle_open (GeditDBus             *dbus,
                   GVariant              *parameters,
                   GDBusMethodInvocation *invocation)
 {
-	GVariant *file_list;
+	GVariantIter *file_list;
 	gchar *charset_encoding;
 	gint line_position;
 	gint column_position;
@@ -673,8 +668,8 @@ dbus_handle_open (GeditDBus             *dbus,
 	               &viewport_x,
 	               &viewport_y);
 
-	locations = variant_file_list_to_locations (file_list);
-	g_variant_unref (file_list);
+	locations = variant_iter_list_to_locations (file_list);
+	g_variant_iter_free (file_list);
 
 	if (charset_encoding && *charset_encoding)
 	{



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