← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~ted/indicator-application/bug703329 into lp:indicator-application

 

Ted Gould has proposed merging lp:~ted/indicator-application/bug703329 into lp:indicator-application.

Requested reviews:
  Indicator Applet Developers (indicator-applet-developers)
Related bugs:
  #703329 indicator-application-service crashed with signal 5 in g_variant_valist_new_nnp()
  https://bugs.launchpad.net/bugs/703329

For more details, see:
https://code.launchpad.net/~ted/indicator-application/bug703329/+merge/47575

Fixes the builder usage.  I'm actually surprised it worked at all :)
-- 
https://code.launchpad.net/~ted/indicator-application/bug703329/+merge/47575
Your team ayatana-commits is subscribed to branch lp:indicator-application.
=== modified file 'src/application-service-appstore.c'
--- src/application-service-appstore.c	2011-01-14 02:25:13 +0000
+++ src/application-service-appstore.c	2011-01-26 18:59:07 +0000
@@ -1156,24 +1156,43 @@
 get_applications (ApplicationServiceAppstore * appstore)
 {
 	ApplicationServiceAppstorePrivate * priv = appstore->priv;
-
-	GVariantBuilder * builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
-	GList * listpntr;
-	gint position = 0;
-
-	for (listpntr = priv->applications; listpntr != NULL; listpntr = g_list_next(listpntr)) {
-		Application * app = (Application *)listpntr->data;
-		if (app->visible_state == VISIBLE_STATE_HIDDEN) {
-			continue;
-		}
-
-		g_variant_builder_add (builder, "(sisosss)", app->icon,
-		                       position++, app->dbus_name, app->menu,
-		                       app->icon_theme_path, app->label,
-		                       app->guide);
-	}
-
-	return g_variant_new("(a(sisosss))", builder);
+	GVariant * out = NULL;
+
+	if (g_list_length(priv->applications) > 0) {
+		GVariantBuilder builder;
+		GList * listpntr;
+		gint position = 0;
+
+		g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY);
+
+		for (listpntr = priv->applications; listpntr != NULL; listpntr = g_list_next(listpntr)) {
+			Application * app = (Application *)listpntr->data;
+			if (app->visible_state == VISIBLE_STATE_HIDDEN) {
+				continue;
+			}
+
+			g_variant_builder_add (&builder, "(sisosss)", app->icon,
+								   position++, app->dbus_name, app->menu,
+								   app->icon_theme_path, app->label,
+								   app->guide);
+		}
+
+		out = g_variant_builder_end(&builder);
+	} else {
+		GError * error = NULL;
+		out = g_variant_parse(g_variant_type_new("a(sisosss)"), "[]", NULL, NULL, &error);
+		if (error != NULL) {
+			g_warning("Unable to parse '[]' as a 'a(sisosss)': %s", error->message);
+			out = NULL;
+			g_error_free(error);
+		}
+	}
+
+	if (out != NULL) {
+		return g_variant_new_tuple(&out, 1);
+	} else {
+		return NULL;
+	}
 }
 
 /* Removes and approver from our list of approvers and


Follow ups