summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2013-11-27 13:03:51 -0500
committerRyan Lortie <desrt@desrt.ca>2013-11-27 13:03:51 -0500
commita06fbabc24c0eedc5ccae5e527e4fed6823b65c2 (patch)
tree0f6996ccf417fdd72ed35034cdd1c87b0910eebf
parent615cbd7990f29d70dca33282695b3a0bbeb89cde (diff)
downloaddconf-a06fbabc24c0eedc5ccae5e527e4fed6823b65c2.tar.gz
engine: filter change signals properly
Testing revealed that we were transmitting any change signal that came in from the bus up to user code, even if the engine in question was not interested in receiving the signal. This is a problem in the case that two DConfClient objects exist for different profiles. In that case, we'd get crosstalk between the subscriptions that each client had made and change notifications would appear in both clients even if the change only affected one.
-rw-r--r--engine/dconf-engine.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/engine/dconf-engine.c b/engine/dconf-engine.c
index c3e5707..33ffd57 100644
--- a/engine/dconf-engine.c
+++ b/engine/dconf-engine.c
@@ -1181,6 +1181,25 @@ dconf_engine_change_sync (DConfEngine *engine,
return TRUE;
}
+static gboolean
+dconf_engine_is_interested_in_signal (DConfEngine *engine,
+ GBusType bus_type,
+ const gchar *sender,
+ const gchar *path)
+{
+ gint i;
+
+ for (i = 0; i < engine->n_sources; i++)
+ {
+ DConfEngineSource *source = engine->sources[i];
+
+ if (source->bus_type == bus_type && g_str_equal (source->object_path, path))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
void
dconf_engine_handle_dbus_signal (GBusType type,
const gchar *sender,
@@ -1215,7 +1234,8 @@ dconf_engine_handle_dbus_signal (GBusType type,
* Check last_handled to determine if we should ignore it.
*/
if (!engine->last_handled || !g_str_equal (engine->last_handled, tag))
- dconf_engine_change_notify (engine, prefix, changes, tag, FALSE, NULL, engine->user_data);
+ if (dconf_engine_is_interested_in_signal (engine, type, sender, path))
+ dconf_engine_change_notify (engine, prefix, changes, tag, FALSE, NULL, engine->user_data);
engines = g_slist_delete_link (engines, engines);
@@ -1244,7 +1264,8 @@ dconf_engine_handle_dbus_signal (GBusType type,
{
DConfEngine *engine = engines->data;
- dconf_engine_change_notify (engine, path, empty_str_list, "", TRUE, NULL, engine->user_data);
+ if (dconf_engine_is_interested_in_signal (engine, type, sender, path))
+ dconf_engine_change_notify (engine, path, empty_str_list, "", TRUE, NULL, engine->user_data);
engines = g_slist_delete_link (engines, engines);