summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllison Lortie <desrt@desrt.ca>2016-10-14 09:35:00 +0200
committerAllison Lortie <desrt@desrt.ca>2016-10-14 10:03:07 +0200
commit8d3bdbbe6228f88c24e46fa7da64eb8b6f5c9e74 (patch)
tree18fd75d9c93c9dd84ae03151b05efafff28e09fb
parent4f0688a7009eb2fd8f7ad5e701cd62b4bb2b4b28 (diff)
downloaddconf-8d3bdbbe6228f88c24e46fa7da64eb8b6f5c9e74.tar.gz
engine: slightly refactor per-source lock-checking
Write a helper function to answer the question of "does this source have any lock for the given key?". Although this logic is currently trivial, it will soon get more complex.
-rw-r--r--engine/dconf-engine.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/engine/dconf-engine.c b/engine/dconf-engine.c
index aca2dd3..251974a 100644
--- a/engine/dconf-engine.c
+++ b/engine/dconf-engine.c
@@ -345,6 +345,16 @@ dconf_engine_get_state (DConfEngine *engine)
}
static gboolean
+dconf_engine_source_has_lock (DConfEngineSource *source,
+ const gchar *key)
+{
+ if (source->locks == NULL)
+ return FALSE;
+
+ return gvdb_table_has_value (source->locks, key);
+}
+
+static gboolean
dconf_engine_is_writable_internal (DConfEngine *engine,
const gchar *key)
{
@@ -370,7 +380,7 @@ dconf_engine_is_writable_internal (DConfEngine *engine,
* thing to do, or it's non-writable and we caught that case above.
*/
for (i = 1; i < engine->n_sources; i++)
- if (engine->sources[i]->locks && gvdb_table_has_value (engine->sources[i]->locks, key))
+ if (dconf_engine_source_has_lock (engine->sources[i], key))
return FALSE;
return TRUE;
@@ -599,7 +609,7 @@ dconf_engine_read (DConfEngine *engine,
*/
if (~flags & DCONF_READ_USER_VALUE)
for (i = engine->n_sources - 1; i > 0; i--)
- if (engine->sources[i]->locks && gvdb_table_has_value (engine->sources[i]->locks, key))
+ if (dconf_engine_source_has_lock (engine->sources[i], key))
{
lock_level = i;
break;