summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2013-11-26 13:38:33 -0500
committerRyan Lortie <desrt@desrt.ca>2013-11-26 13:46:13 -0500
commiteb8f17c4c59ab480007f5ead6949388297b00e74 (patch)
tree3855cdf48da9950274c667e016b8a9daa4548e04
parent735d95a845ac886355da00f5b0a565bfcaeb9534 (diff)
downloaddconf-eb8f17c4c59ab480007f5ead6949388297b00e74.tar.gz
engine: add 'profile' argument to constructor
Allow specifying a profile when calling dconf_engine_new(). This will allow us to avoid setting/unsetting the DCONF_PROFILE environment in testcases from contexts where other threads may be reading from the environment.
-rw-r--r--client/dconf-client.c2
-rw-r--r--dbus-1/dconf-dbus-1.c2
-rw-r--r--engine/dconf-engine.c7
-rw-r--r--engine/dconf-engine.h3
-rw-r--r--gsettings/dconfsettingsbackend.c2
-rw-r--r--tests/engine.c12
6 files changed, 15 insertions, 13 deletions
diff --git a/client/dconf-client.c b/client/dconf-client.c
index db281d0..5832780 100644
--- a/client/dconf-client.c
+++ b/client/dconf-client.c
@@ -214,7 +214,7 @@ dconf_client_new (void)
client = g_object_new (DCONF_TYPE_CLIENT, NULL);
weak_ref = g_slice_new (GWeakRef);
g_weak_ref_init (weak_ref, client);
- client->engine = dconf_engine_new (weak_ref, dconf_client_free_weak_ref);
+ client->engine = dconf_engine_new (NULL, weak_ref, dconf_client_free_weak_ref);
client->context = g_main_context_ref_thread_default ();
return client;
diff --git a/dbus-1/dconf-dbus-1.c b/dbus-1/dconf-dbus-1.c
index 840e1ae..a4d7907 100644
--- a/dbus-1/dconf-dbus-1.c
+++ b/dbus-1/dconf-dbus-1.c
@@ -160,7 +160,7 @@ dconf_dbus_client_new (const gchar *profile,
dconf_libdbus_1_provide_bus (G_BUS_TYPE_SYSTEM, system);
dcdbc = g_slice_new (DConfDBusClient);
- dcdbc->engine = dconf_engine_new (dcdbc, NULL);
+ dcdbc->engine = dconf_engine_new (NULL, dcdbc, NULL);
dcdbc->watches = NULL;
dcdbc->ref_count = 1;
diff --git a/engine/dconf-engine.c b/engine/dconf-engine.c
index af98cdf..5492098 100644
--- a/engine/dconf-engine.c
+++ b/engine/dconf-engine.c
@@ -224,8 +224,9 @@ dconf_engine_unlock_queues (DConfEngine *engine)
}
DConfEngine *
-dconf_engine_new (gpointer user_data,
- GDestroyNotify free_func)
+dconf_engine_new (const gchar *profile,
+ gpointer user_data,
+ GDestroyNotify free_func)
{
DConfEngine *engine;
@@ -238,7 +239,7 @@ dconf_engine_new (gpointer user_data,
g_mutex_init (&engine->queue_lock);
g_cond_init (&engine->queue_cond);
- engine->sources = dconf_engine_profile_open (NULL, &engine->n_sources);
+ engine->sources = dconf_engine_profile_open (profile, &engine->n_sources);
g_mutex_lock (&dconf_engine_global_lock);
dconf_engine_global_list = g_slist_prepend (dconf_engine_global_list, engine);
diff --git a/engine/dconf-engine.h b/engine/dconf-engine.h
index 0b969a2..cac631f 100644
--- a/engine/dconf-engine.h
+++ b/engine/dconf-engine.h
@@ -97,7 +97,8 @@ void dconf_engine_handle_dbus_signal (GBusTyp
GVariant *parameters);
G_GNUC_INTERNAL
-DConfEngine * dconf_engine_new (gpointer user_data,
+DConfEngine * dconf_engine_new (const gchar *profile,
+ gpointer user_data,
GDestroyNotify free_func);
G_GNUC_INTERNAL
diff --git a/gsettings/dconfsettingsbackend.c b/gsettings/dconfsettingsbackend.c
index b0ad4d0..9db10f7 100644
--- a/gsettings/dconfsettingsbackend.c
+++ b/gsettings/dconfsettingsbackend.c
@@ -183,7 +183,7 @@ dconf_settings_backend_init (DConfSettingsBackend *dcsb)
weak_ref = g_slice_new (GWeakRef);
g_weak_ref_init (weak_ref, dcsb);
- dcsb->engine = dconf_engine_new (weak_ref, dconf_settings_backend_free_weak_ref);
+ dcsb->engine = dconf_engine_new (NULL, weak_ref, dconf_settings_backend_free_weak_ref);
}
static void
diff --git a/tests/engine.c b/tests/engine.c
index 8db0f17..abf3000 100644
--- a/tests/engine.c
+++ b/tests/engine.c
@@ -221,7 +221,7 @@ test_signal_threadsafety_worker (gpointer user_data)
{
DConfEngine *engine;
- engine = dconf_engine_new (NULL, NULL);
+ engine = dconf_engine_new (NULL, NULL, NULL);
dconf_engine_unref (engine);
}
@@ -1055,7 +1055,7 @@ test_read (void)
setup_state (n, i, j, (j != k) ? state : NULL);
/* Step 3: create the engine */
- engine = dconf_engine_new (NULL, NULL);
+ engine = dconf_engine_new (NULL, NULL, NULL);
/* Step 4: read, and check result */
check_read (engine, n, i, j);
@@ -1107,7 +1107,7 @@ test_watch_fast (void)
triv = g_variant_ref_sink (g_variant_new ("()"));
g_setenv ("DCONF_PROFILE", SRCDIR "/profile/dos", TRUE);
- engine = dconf_engine_new (NULL, NULL);
+ engine = dconf_engine_new (NULL, NULL, NULL);
g_unsetenv ("DCONF_PROFILE");
/* Check that establishing a watch works properly in the normal case.
@@ -1196,7 +1196,7 @@ test_watch_sync (void)
dconf_mock_dbus_sync_call_handler = handle_match_request;
g_setenv ("DCONF_PROFILE", SRCDIR "/profile/dos", TRUE);
- engine = dconf_engine_new (NULL, NULL);
+ engine = dconf_engine_new (NULL, NULL, NULL);
g_unsetenv ("DCONF_PROFILE");
match_request_type = "AddMatch";
@@ -1246,7 +1246,7 @@ test_change_fast (void)
dconf_changeset_set (slightly_bad_write, "/to-reset", NULL);
g_setenv ("DCONF_PROFILE", SRCDIR "/profile/dos", TRUE);
- engine = dconf_engine_new (NULL, NULL);
+ engine = dconf_engine_new (NULL, NULL, NULL);
g_unsetenv ("DCONF_PROFILE");
success = dconf_engine_change_fast (engine, empty, NULL, &error);
@@ -1426,7 +1426,7 @@ test_change_sync (void)
dconf_changeset_set (slightly_bad_write, "/to-reset", NULL);
g_setenv ("DCONF_PROFILE", SRCDIR "/profile/dos", TRUE);
- engine = dconf_engine_new (NULL, NULL);
+ engine = dconf_engine_new (NULL, NULL, NULL);
g_unsetenv ("DCONF_PROFILE");
success = dconf_engine_change_sync (engine, empty, &tag, &error);