mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-03 22:52:09 +01:00
Don't use GIO in GTestDBus setup
Using GIO here may cause the gvfs module to be loaded, which in turn gets onto the session bus to talk to gvfsd - not ideal if you are trying to control the session bus life cycle. Instead, just use old-fashioned glib file utils.
This commit is contained in:
parent
197ebb3be4
commit
b55a2a2005
@ -453,18 +453,17 @@ g_test_dbus_class_init (GTestDBusClass *klass)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GFile *
|
static gchar *
|
||||||
write_config_file (GTestDBus *self)
|
write_config_file (GTestDBus *self)
|
||||||
{
|
{
|
||||||
GString *contents;
|
GString *contents;
|
||||||
GFile *file;
|
gint fd;
|
||||||
GFileIOStream *iostream;
|
|
||||||
guint i;
|
guint i;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
gchar *path = NULL;
|
||||||
|
|
||||||
file = g_file_new_tmp ("g-test-dbus-XXXXXX", &iostream, &error);
|
fd = g_file_open_tmp ("g-test-dbus-XXXXXX", &path, &error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
g_object_unref (iostream);
|
|
||||||
|
|
||||||
contents = g_string_new (NULL);
|
contents = g_string_new (NULL);
|
||||||
g_string_append (contents,
|
g_string_append (contents,
|
||||||
@ -496,20 +495,20 @@ write_config_file (GTestDBus *self)
|
|||||||
" </policy>\n"
|
" </policy>\n"
|
||||||
"</busconfig>\n");
|
"</busconfig>\n");
|
||||||
|
|
||||||
g_file_replace_contents (file, contents->str, contents->len,
|
g_file_set_contents (path, contents->str, contents->len, &error);
|
||||||
NULL, FALSE, G_FILE_CREATE_NONE, NULL, NULL, &error);
|
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
|
|
||||||
g_string_free (contents, TRUE);
|
g_string_free (contents, TRUE);
|
||||||
|
|
||||||
return file;
|
close (fd);
|
||||||
|
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
start_daemon (GTestDBus *self)
|
start_daemon (GTestDBus *self)
|
||||||
{
|
{
|
||||||
gchar *argv[] = {"dbus-daemon", "--print-address", "--config-file=foo", NULL};
|
gchar *argv[] = {"dbus-daemon", "--print-address", "--config-file=foo", NULL};
|
||||||
GFile *file;
|
|
||||||
gchar *config_path;
|
gchar *config_path;
|
||||||
gchar *config_arg;
|
gchar *config_arg;
|
||||||
gint stdout_fd;
|
gint stdout_fd;
|
||||||
@ -521,9 +520,7 @@ start_daemon (GTestDBus *self)
|
|||||||
argv[0] = (gchar *)g_getenv ("G_TEST_DBUS_DAEMON");
|
argv[0] = (gchar *)g_getenv ("G_TEST_DBUS_DAEMON");
|
||||||
|
|
||||||
/* Write config file and set its path in argv */
|
/* Write config file and set its path in argv */
|
||||||
file = write_config_file (self);
|
config_path = write_config_file (self);
|
||||||
config_path = g_file_get_path (file);
|
|
||||||
g_object_unref (file);
|
|
||||||
config_arg = g_strdup_printf ("--config-file=%s", config_path);
|
config_arg = g_strdup_printf ("--config-file=%s", config_path);
|
||||||
argv[2] = config_arg;
|
argv[2] = config_arg;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user