mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-11 11:56:16 +01:00
Merge branch 'mcatanzaro/kfsb' into 'master'
gkeyfilesettingsbackend: check for errors when creating file monitors See merge request GNOME/glib!1961
This commit is contained in:
commit
17889df81a
@ -605,19 +605,24 @@ g_keyfile_settings_backend_finalize (GObject *object)
|
|||||||
g_hash_table_unref (kfsb->system_locks);
|
g_hash_table_unref (kfsb->system_locks);
|
||||||
g_free (kfsb->defaults_dir);
|
g_free (kfsb->defaults_dir);
|
||||||
|
|
||||||
g_file_monitor_cancel (kfsb->file_monitor);
|
if (kfsb->file_monitor)
|
||||||
g_object_unref (kfsb->file_monitor);
|
{
|
||||||
|
g_file_monitor_cancel (kfsb->file_monitor);
|
||||||
|
g_object_unref (kfsb->file_monitor);
|
||||||
|
}
|
||||||
g_object_unref (kfsb->file);
|
g_object_unref (kfsb->file);
|
||||||
|
|
||||||
g_file_monitor_cancel (kfsb->dir_monitor);
|
if (kfsb->dir_monitor)
|
||||||
g_object_unref (kfsb->dir_monitor);
|
{
|
||||||
|
g_file_monitor_cancel (kfsb->dir_monitor);
|
||||||
|
g_object_unref (kfsb->dir_monitor);
|
||||||
|
}
|
||||||
g_object_unref (kfsb->dir);
|
g_object_unref (kfsb->dir);
|
||||||
|
|
||||||
g_free (kfsb->root_group);
|
g_free (kfsb->root_group);
|
||||||
g_free (kfsb->prefix);
|
g_free (kfsb->prefix);
|
||||||
|
|
||||||
G_OBJECT_CLASS (g_keyfile_settings_backend_parent_class)
|
G_OBJECT_CLASS (g_keyfile_settings_backend_parent_class)->finalize (object);
|
||||||
->finalize (object);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -724,6 +729,7 @@ static void
|
|||||||
g_keyfile_settings_backend_constructed (GObject *object)
|
g_keyfile_settings_backend_constructed (GObject *object)
|
||||||
{
|
{
|
||||||
GKeyfileSettingsBackend *kfsb = G_KEYFILE_SETTINGS_BACKEND (object);
|
GKeyfileSettingsBackend *kfsb = G_KEYFILE_SETTINGS_BACKEND (object);
|
||||||
|
GError *error = NULL;
|
||||||
const char *path;
|
const char *path;
|
||||||
|
|
||||||
if (kfsb->file == NULL)
|
if (kfsb->file == NULL)
|
||||||
@ -749,16 +755,32 @@ g_keyfile_settings_backend_constructed (GObject *object)
|
|||||||
if (g_mkdir_with_parents (path, 0700) == -1)
|
if (g_mkdir_with_parents (path, 0700) == -1)
|
||||||
g_warning ("Failed to create %s: %s", path, g_strerror (errno));
|
g_warning ("Failed to create %s: %s", path, g_strerror (errno));
|
||||||
|
|
||||||
kfsb->file_monitor = g_file_monitor (kfsb->file, G_FILE_MONITOR_NONE, NULL, NULL);
|
kfsb->file_monitor = g_file_monitor (kfsb->file, G_FILE_MONITOR_NONE, NULL, &error);
|
||||||
kfsb->dir_monitor = g_file_monitor (kfsb->dir, G_FILE_MONITOR_NONE, NULL, NULL);
|
if (!kfsb->file_monitor)
|
||||||
|
{
|
||||||
|
g_warning ("Failed to create file monitor for %s: %s", g_file_peek_path (kfsb->file), error->message);
|
||||||
|
g_clear_error (&error);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_signal_connect (kfsb->file_monitor, "changed",
|
||||||
|
G_CALLBACK (file_changed), kfsb);
|
||||||
|
}
|
||||||
|
|
||||||
|
kfsb->dir_monitor = g_file_monitor (kfsb->dir, G_FILE_MONITOR_NONE, NULL, &error);
|
||||||
|
if (!kfsb->dir_monitor)
|
||||||
|
{
|
||||||
|
g_warning ("Failed to create file monitor for %s: %s", g_file_peek_path (kfsb->file), error->message);
|
||||||
|
g_clear_error (&error);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_signal_connect (kfsb->dir_monitor, "changed",
|
||||||
|
G_CALLBACK (dir_changed), kfsb);
|
||||||
|
}
|
||||||
|
|
||||||
compute_checksum (kfsb->digest, NULL, 0);
|
compute_checksum (kfsb->digest, NULL, 0);
|
||||||
|
|
||||||
g_signal_connect (kfsb->file_monitor, "changed",
|
|
||||||
G_CALLBACK (file_changed), kfsb);
|
|
||||||
g_signal_connect (kfsb->dir_monitor, "changed",
|
|
||||||
G_CALLBACK (dir_changed), kfsb);
|
|
||||||
|
|
||||||
g_keyfile_settings_backend_keyfile_writable (kfsb);
|
g_keyfile_settings_backend_keyfile_writable (kfsb);
|
||||||
g_keyfile_settings_backend_keyfile_reload (kfsb);
|
g_keyfile_settings_backend_keyfile_reload (kfsb);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user