[Xfce4-commits] [apps/mousepad] 35/45: Remove mutex locking around global settings object
noreply at xfce.org
noreply at xfce.org
Fri Jul 11 13:03:40 CEST 2014
This is an automated email from the git hooks/post-receive script.
mbrush pushed a commit to branch master
in repository apps/mousepad.
commit 1c4dcd9b117d0cefb6c18fda02311a056e9481a7
Author: Matthew Brush <mbrush at codebrainz.ca>
Date: Thu Jul 10 12:19:55 2014 -0700
Remove mutex locking around global settings object
Not using threads at this point anyway and using it at this level
causes deadlocks when functions watching for settings changes call
back in to get/set the settings. In the future if threads are used,
access to the global settings instance should be locked by the caller
or some other mechanism put in places.
---
mousepad/mousepad-settings.c | 39 +++------------------------------------
1 file changed, 3 insertions(+), 36 deletions(-)
diff --git a/mousepad/mousepad-settings.c b/mousepad/mousepad-settings.c
index 38d1034..d5643e9 100644
--- a/mousepad/mousepad-settings.c
+++ b/mousepad/mousepad-settings.c
@@ -6,12 +6,6 @@
-G_LOCK_DEFINE (settings_lock);
-#define MOUSEPAD_SETTINGS_LOCK() G_LOCK (settings_lock)
-#define MOUSEPAD_SETTINGS_UNLOCK() G_UNLOCK (settings_lock)
-
-
-
static MousepadSettingsStore *settings_store = NULL;
static gint settings_init_count = 0;
@@ -20,18 +14,11 @@ static gint settings_init_count = 0;
void
mousepad_settings_finalize (void)
{
- MOUSEPAD_SETTINGS_LOCK ();
-
g_settings_sync ();
settings_init_count--;
if (settings_init_count > 0)
- {
- MOUSEPAD_SETTINGS_UNLOCK ();
- return;
- }
-
- MOUSEPAD_SETTINGS_UNLOCK ();
+ return;
if (MOUSEPAD_IS_SETTINGS_STORE (settings_store))
{
@@ -46,8 +33,6 @@ void
mousepad_settings_init (void)
{
- MOUSEPAD_SETTINGS_LOCK ();
-
if (settings_init_count == 0)
{
if (! MOUSEPAD_IS_SETTINGS_STORE (settings_store))
@@ -55,8 +40,6 @@ mousepad_settings_init (void)
}
settings_init_count++;
-
- MOUSEPAD_SETTINGS_UNLOCK ();
}
@@ -77,9 +60,7 @@ mousepad_setting_bind (const gchar *path,
if (mousepad_settings_store_lookup (settings_store, path, &key_name, &settings))
{
- MOUSEPAD_SETTINGS_LOCK ();
g_settings_bind (settings, key_name, object, prop, flags);
- MOUSEPAD_SETTINGS_UNLOCK ();
return TRUE;
}
@@ -107,14 +88,12 @@ mousepad_setting_connect (const gchar *path,
signal_name = g_strdup_printf ("changed::%s", key_name);
- MOUSEPAD_SETTINGS_LOCK ();
signal_id = g_signal_connect_data (settings,
signal_name,
callback,
user_data,
NULL,
connect_flags);
- MOUSEPAD_SETTINGS_UNLOCK ();
g_free (signal_name);
}
@@ -160,9 +139,7 @@ mousepad_setting_get (const gchar *path,
GVariant *variant;
va_list ap;
- MOUSEPAD_SETTINGS_LOCK ();
variant = g_settings_get_value (settings, key_name);
- MOUSEPAD_SETTINGS_UNLOCK ();
g_variant_ref_sink (variant);
@@ -203,9 +180,7 @@ mousepad_setting_set (const gchar *path,
g_variant_ref_sink (variant);
- MOUSEPAD_SETTINGS_LOCK ();
g_settings_set_value (settings, key_name, variant);
- MOUSEPAD_SETTINGS_UNLOCK ();
g_variant_unref (variant);
@@ -288,11 +263,7 @@ mousepad_setting_get_enum (const gchar *path)
g_return_val_if_fail (path != NULL, FALSE);
if (mousepad_settings_store_lookup (settings_store, path, &key_name, &settings))
- {
- MOUSEPAD_SETTINGS_LOCK ();
- result = g_settings_get_enum (settings, key_name);
- MOUSEPAD_SETTINGS_UNLOCK ();
- }
+ result = g_settings_get_enum (settings, key_name);
else
g_warn_if_reached ();
@@ -311,11 +282,7 @@ mousepad_setting_set_enum (const gchar *path,
g_return_val_if_fail (path != NULL, FALSE);
if (mousepad_settings_store_lookup (settings_store, path, &key_name, &settings))
- {
- MOUSEPAD_SETTINGS_LOCK ();
- g_settings_set_enum (settings, key_name, value);
- MOUSEPAD_SETTINGS_UNLOCK ();
- }
+ g_settings_set_enum (settings, key_name, value);
else
g_warn_if_reached ();
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list