diff options
author | Chun-wei Fan <fanchunwei@src.gnome.org> | 2014-11-20 18:34:21 +0800 |
---|---|---|
committer | Chun-wei Fan <fanchunwei@src.gnome.org> | 2014-11-20 22:11:25 +0800 |
commit | f6bbd19beb41aeb52426ba96b3c39c1b09f6bc17 (patch) | |
tree | 08ee4d588cad0966908ee14a32d3f52810844296 /gio/gregistrysettingsbackend.c | |
parent | 5c68fc9f93ee3d3cdb94cda2be5565584dfbb908 (diff) |
GSettings Registry Backend: Init cache_lock Earlier
In commit 8ff5668, we are subscribing the GSettings backend later, but this
meant that we need to initialize cache_lock earlier, as we might try to
use that lock before a change notification is issued to subscribe the
backend, which would then cause an access violation if we are trying to
read GSettings values, as that lock is used to access the Windows Registry.
Initialize cache_lock once we initialize the GSettings Registry backend,
and delete it upon finalize, so that g_settings_read_from_backend() can
proceed normally, even if the GSettings backend is not yet subscribed.
https://bugzilla.gnome.org/show_bug.cgi?id=740413
Diffstat (limited to 'gio/gregistrysettingsbackend.c')
-rw-r--r-- | gio/gregistrysettingsbackend.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/gio/gregistrysettingsbackend.c b/gio/gregistrysettingsbackend.c index cf9da0b79..96df52c57 100644 --- a/gio/gregistrysettingsbackend.c +++ b/gio/gregistrysettingsbackend.c @@ -1654,9 +1654,6 @@ watch_start (GRegistryBackend *self) g_return_val_if_fail (self->watch == NULL, FALSE); - self->cache_lock = g_slice_new (CRITICAL_SECTION); - InitializeCriticalSection (self->cache_lock); - watch = g_slice_new (WatchThreadState); watch->owner = G_SETTINGS_BACKEND (self); @@ -1685,8 +1682,6 @@ watch_start (GRegistryBackend *self) return TRUE; fail_2: - DeleteCriticalSection (self->cache_lock); - g_slice_free (CRITICAL_SECTION, self->cache_lock); DeleteCriticalSection (watch->message_lock); g_slice_free (CRITICAL_SECTION, watch->message_lock); CloseHandle (watch->message_sent_event); @@ -1720,9 +1715,7 @@ watch_stop_unlocked (GRegistryBackend *self) LeaveCriticalSection (watch->message_lock); DeleteCriticalSection (watch->message_lock); - DeleteCriticalSection (self->cache_lock); g_slice_free (CRITICAL_SECTION, watch->message_lock); - g_slice_free (CRITICAL_SECTION, self->cache_lock); CloseHandle (watch->message_sent_event); CloseHandle (watch->message_received_event); CloseHandle (watch->thread); @@ -1936,6 +1929,9 @@ g_registry_backend_finalize (GObject *object) watch_stop_unlocked (self); } + DeleteCriticalSection (self->cache_lock); + g_slice_free (CRITICAL_SECTION, self->cache_lock); + g_free (self->base_path); } @@ -1970,5 +1966,8 @@ g_registry_backend_init (GRegistryBackend *self) item->ref_count = 1; self->cache_root = g_node_new (item); + self->cache_lock = g_slice_new (CRITICAL_SECTION); + InitializeCriticalSection (self->cache_lock); + self->watch = NULL; } |