aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib/client.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2012-03-01 10:55:24 -0600
committerTed Gould <ted@gould.cx>2012-03-01 10:55:24 -0600
commit4592b138187df94f644aae46bd1a6f0913a4c05b (patch)
tree0aea7abc7b27c6df55c1ac0c8dc794a6330c3e45 /libdbusmenu-glib/client.c
parent3a9221c21feb1701119db5079bf3e350c0cb0aac (diff)
downloadlibdbusmenu-4592b138187df94f644aae46bd1a6f0913a4c05b.tar.gz
libdbusmenu-4592b138187df94f644aae46bd1a6f0913a4c05b.tar.bz2
libdbusmenu-4592b138187df94f644aae46bd1a6f0913a4c05b.zip
Clean up a goto and make the lifecycles of the variables more clear
Diffstat (limited to 'libdbusmenu-glib/client.c')
-rw-r--r--libdbusmenu-glib/client.c86
1 files changed, 44 insertions, 42 deletions
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c
index e64d923..01f063d 100644
--- a/libdbusmenu-glib/client.c
+++ b/libdbusmenu-glib/client.c
@@ -601,64 +601,66 @@ get_properties_callback (GObject *obj, GAsyncResult * res, gpointer user_data)
listener->callback(NULL, error, listener->user_data);
}
g_error_free(error);
- goto out;
}
/* Callback all the folks we can find */
- GVariant * parent = g_variant_get_child_value(params, 0);
- GVariantIter iter;
- g_variant_iter_init(&iter, parent);
- GVariant * child;
- while ((child = g_variant_iter_next_value(&iter)) != NULL) {
- if (g_strcmp0(g_variant_get_type_string(child), "(ia{sv})") != 0) {
- g_warning("Properties return signature is not '(ia{sv})' it is '%s'", g_variant_get_type_string(child));
- g_variant_unref(child);
- continue;
- }
+ if (error == NULL) {
+ GVariant * parent = g_variant_get_child_value(params, 0);
+ GVariantIter iter;
+ g_variant_iter_init(&iter, parent);
+ GVariant * child;
+ while ((child = g_variant_iter_next_value(&iter)) != NULL) {
+ if (g_strcmp0(g_variant_get_type_string(child), "(ia{sv})") != 0) {
+ g_warning("Properties return signature is not '(ia{sv})' it is '%s'", g_variant_get_type_string(child));
+ g_variant_unref(child);
+ continue;
+ }
- GVariant * idv = g_variant_get_child_value(child, 0);
- gint id = g_variant_get_int32(idv);
- g_variant_unref(idv);
+ GVariant * idv = g_variant_get_child_value(child, 0);
+ gint id = g_variant_get_int32(idv);
+ g_variant_unref(idv);
+
+ GVariant * properties = g_variant_get_child_value(child, 1);
- GVariant * properties = g_variant_get_child_value(child, 1);
+ properties_listener_t * listener = find_listener(listeners, 0, id);
+ if (listener == NULL) {
+ g_warning("Unable to find listener for ID %d", id);
+ g_variant_unref(properties);
+ g_variant_unref(child);
+ continue;
+ }
- properties_listener_t * listener = find_listener(listeners, 0, id);
- if (listener == NULL) {
- g_warning("Unable to find listener for ID %d", id);
+ if (!listener->replied) {
+ listener->callback(properties, NULL, listener->user_data);
+ listener->replied = TRUE;
+ } else {
+ g_warning("Odd, we've already replied to the listener on ID %d", id);
+ }
g_variant_unref(properties);
g_variant_unref(child);
- continue;
}
-
- if (!listener->replied) {
- listener->callback(properties, NULL, listener->user_data);
- listener->replied = TRUE;
- } else {
- g_warning("Odd, we've already replied to the listener on ID %d", id);
- }
- g_variant_unref(properties);
- g_variant_unref(child);
+ g_variant_unref(parent);
+ g_variant_unref(params);
}
- g_variant_unref(parent);
- g_variant_unref(params);
/* Provide errors for those who we can't */
- GError * localerror = NULL;
- for (i = 0; i < listeners->len; i++) {
- properties_listener_t * listener = &g_array_index(listeners, properties_listener_t, i);
- if (!listener->replied) {
- g_warning("Generating properties error for: %d", listener->id);
- if (localerror == NULL) {
- g_set_error_literal(&localerror, error_domain(), 0, "Error getting properties for ID");
+ if (error == NULL && listeners->len > 0) {
+ GError * localerror = NULL;
+ for (i = 0; i < listeners->len; i++) {
+ properties_listener_t * listener = &g_array_index(listeners, properties_listener_t, i);
+ if (!listener->replied) {
+ g_warning("Generating properties error for: %d", listener->id);
+ if (localerror == NULL) {
+ g_set_error_literal(&localerror, error_domain(), 0, "Error getting properties for ID");
+ }
+ listener->callback(NULL, localerror, listener->user_data);
}
- listener->callback(NULL, localerror, listener->user_data);
}
- }
- if (localerror != NULL) {
- g_error_free(localerror);
+ if (localerror != NULL) {
+ g_error_free(localerror);
+ }
}
-out:
/* Clean up */
g_array_free(listeners, TRUE);
g_object_unref(cbdata->client);