aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2012-02-09 12:58:29 -0600
committerTed Gould <ted@gould.cx>2012-02-09 12:58:29 -0600
commitc3467a14ee0ff76b51d5771614153cc6810352ac (patch)
treec77750898cafb681d2087d0939fa1887c4424dc4
parent8d7a4ec5cbf30119b0ec553174853556a480228a (diff)
downloadlibdbusmenu-c3467a14ee0ff76b51d5771614153cc6810352ac.tar.gz
libdbusmenu-c3467a14ee0ff76b51d5771614153cc6810352ac.tar.bz2
libdbusmenu-c3467a14ee0ff76b51d5771614153cc6810352ac.zip
Making it so that we ref_sink() the variants so that when we unref them later we're not in a race condition with the gdbus thread
-rw-r--r--libdbusmenu-glib/server.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c
index 4890d37..c992085 100644
--- a/libdbusmenu-glib/server.c
+++ b/libdbusmenu-glib/server.c
@@ -990,6 +990,7 @@ menuitem_property_idle (gpointer user_data)
/* these are going to be standard references in all code paths and must be unrefed */
GVariant * megadata[2];
gboolean gotsomething = FALSE;
+ gboolean error_nosend = FALSE;
if (item_init) {
megadata[0] = g_variant_builder_end(&itembuilder);
@@ -1002,6 +1003,10 @@ menuitem_property_idle (gpointer user_data)
if (error != NULL) {
g_warning("Unable to parse '[ ]' as a 'a(ia{sv})': %s", error->message);
g_error_free(error);
+ megadata[0] = NULL;
+ error_nosend = TRUE;
+ } else {
+ g_variant_ref_sink(megadata[0]);
}
}
@@ -1016,10 +1021,14 @@ menuitem_property_idle (gpointer user_data)
if (error != NULL) {
g_warning("Unable to parse '[ ]' as a 'a(ias)': %s", error->message);
g_error_free(error);
+ megadata[1] = NULL;
+ error_nosend = TRUE;
+ } else {
+ g_variant_ref_sink(megadata[1]);
}
}
- if (gotsomething && priv->dbusobject != NULL && priv->bus != NULL) {
+ if (gotsomething && !error_nosend && priv->dbusobject != NULL && priv->bus != NULL) {
g_dbus_connection_emit_signal(priv->bus,
NULL,
priv->dbusobject,
@@ -1029,8 +1038,13 @@ menuitem_property_idle (gpointer user_data)
NULL);
}
- g_variant_unref(megadata[0]);
- g_variant_unref(megadata[1]);
+ if (megadata[0] != NULL) {
+ g_variant_unref(megadata[0]);
+ }
+
+ if (megadata[1] != NULL) {
+ g_variant_unref(megadata[1]);
+ }
/* Clean everything up */
prop_array_teardown(priv->prop_array);