[gthumb] removed the use of g_mutex_new
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] removed the use of g_mutex_new
- Date: Sun, 2 Dec 2012 11:21:18 +0000 (UTC)
commit 742b8428b61db296a4119443857985744f573572
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun Nov 4 14:40:12 2012 +0100
removed the use of g_mutex_new
extensions/selections/gth-selections-manager.c | 30 ++++++++++++------------
gthumb/gnome-desktop-thumbnail.c | 29 ++++++++++------------
gthumb/gth-async-task.c | 30 ++++++++++++------------
gthumb/gth-hook.c | 14 +++++-----
4 files changed, 50 insertions(+), 53 deletions(-)
---
diff --git a/extensions/selections/gth-selections-manager.c b/extensions/selections/gth-selections-manager.c
index 93e5213..7e101fa 100644
--- a/extensions/selections/gth-selections-manager.c
+++ b/extensions/selections/gth-selections-manager.c
@@ -32,7 +32,7 @@ struct _GthSelectionsManagerPrivate {
GHashTable *files_hash[GTH_SELECTIONS_MANAGER_N_SELECTIONS];
char *order[GTH_SELECTIONS_MANAGER_N_SELECTIONS];
gboolean order_inverse[GTH_SELECTIONS_MANAGER_N_SELECTIONS];
- GMutex *mutex;
+ GMutex mutex;
};
@@ -75,7 +75,7 @@ gth_selections_manager_finalize (GObject *object)
g_hash_table_unref (self->priv->files_hash[i]);
g_free (self->priv->order[i]);
}
- g_mutex_free (self->priv->mutex);
+ g_mutex_clear (&self->priv->mutex);
G_OBJECT_CLASS (gth_selections_manager_parent_class)->finalize (object);
}
@@ -99,7 +99,7 @@ gth_selections_manager_init (GthSelectionsManager *self)
int i;
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_SELECTIONS_MANAGER, GthSelectionsManagerPrivate);
- self->priv->mutex = g_mutex_new ();
+ g_mutex_init (&self->priv->mutex);
for (i = 0; i < GTH_SELECTIONS_MANAGER_N_SELECTIONS; i++) {
self->priv->files[i] = NULL;
self->priv->files_hash[i] = g_hash_table_new (g_file_hash, (GEqualFunc) g_file_equal);
@@ -319,7 +319,7 @@ gth_selections_manager_for_each_child (GFile *folder,
self = gth_selections_manager_get_default ();
n_selection = _g_file_get_n_selection (folder);
- g_mutex_lock (self->priv->mutex);
+ g_mutex_lock (&self->priv->mutex);
data = g_new0 (ForEachChildData, 1);
data->selections_manager = self;
if (n_selection > 0)
@@ -330,7 +330,7 @@ gth_selections_manager_for_each_child (GFile *folder,
data->for_each_file_func = for_each_file_func;
data->ready_callback = ready_callback;
data->user_data = user_data;
- g_mutex_unlock (self->priv->mutex);
+ g_mutex_unlock (&self->priv->mutex);
if (n_selection == 0) {
call_when_idle (_gth_selections_manager_for_each_selection, data);
@@ -367,7 +367,7 @@ gth_selections_manager_add_files (GFile *folder,
if (n_selection <= 0)
return FALSE;
- g_mutex_lock (self->priv->mutex);
+ g_mutex_lock (&self->priv->mutex);
new_list = _g_file_list_dup (file_list);
@@ -397,7 +397,7 @@ gth_selections_manager_add_files (GFile *folder,
file_list,
GTH_MONITOR_EVENT_CREATED);
- g_mutex_unlock (self->priv->mutex);
+ g_mutex_unlock (&self->priv->mutex);
return TRUE;
}
@@ -418,7 +418,7 @@ gth_selections_manager_remove_files (GFile *folder,
if (n_selection <= 0)
return;
- g_mutex_lock (self->priv->mutex);
+ g_mutex_lock (&self->priv->mutex);
files_to_remove = g_hash_table_new (g_file_hash, (GEqualFunc) g_file_equal);
for (scan = file_list; scan; scan = scan->next) {
@@ -448,7 +448,7 @@ gth_selections_manager_remove_files (GFile *folder,
GTH_MONITOR_EVENT_REMOVED);
gth_monitor_emblems_changed (gth_main_get_default_monitor (), file_list);
- g_mutex_unlock (self->priv->mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
@@ -471,7 +471,7 @@ gth_selections_manager_reorder (GFile *folder,
/* reorder the file list */
- g_mutex_lock (self->priv->mutex);
+ g_mutex_lock (&self->priv->mutex);
_g_list_reorder (self->priv->files[n_selection - 1],
visible_files,
files_to_move,
@@ -480,7 +480,7 @@ gth_selections_manager_reorder (GFile *folder,
&new_file_list);
_g_object_list_unref (self->priv->files[n_selection - 1]);
self->priv->files[n_selection - 1] = new_file_list;
- g_mutex_unlock (self->priv->mutex);
+ g_mutex_unlock (&self->priv->mutex);
gth_selections_manager_set_sort_type (folder, "general::unsorted", FALSE);
@@ -505,13 +505,13 @@ gth_selections_manager_set_sort_type (GFile *folder,
return;
self = gth_selections_manager_get_default ();
- g_mutex_lock (self->priv->mutex);
+ g_mutex_lock (&self->priv->mutex);
g_free (self->priv->order[n_selection - 1]);
self->priv->order[n_selection - 1] = g_strdup (sort_type);
self->priv->order_inverse[n_selection - 1] = sort_inverse;
- g_mutex_unlock (self->priv->mutex);
+ g_mutex_unlock (&self->priv->mutex);
}
@@ -526,11 +526,11 @@ gth_selections_manager_file_exists (int n_selection,
return FALSE;
self = gth_selections_manager_get_default ();
- g_mutex_lock (self->priv->mutex);
+ g_mutex_lock (&self->priv->mutex);
result = (g_hash_table_lookup (self->priv->files_hash[n_selection - 1], file) != NULL);
- g_mutex_unlock (self->priv->mutex);
+ g_mutex_unlock (&self->priv->mutex);
return result;
}
diff --git a/gthumb/gnome-desktop-thumbnail.c b/gthumb/gnome-desktop-thumbnail.c
index 41552b5..2356bf5 100644
--- a/gthumb/gnome-desktop-thumbnail.c
+++ b/gthumb/gnome-desktop-thumbnail.c
@@ -70,7 +70,7 @@ struct _GnomeDesktopThumbnailFactoryPrivate {
GnomeDesktopThumbnailSize size;
gboolean use_xdg_dir;
- GMutex *lock;
+ GMutex lock;
GList *thumbnailers;
GHashTable *mime_types_map;
@@ -496,7 +496,7 @@ update_or_create_thumbnailer (GnomeDesktopThumbnailFactory *factory,
Thumbnailer *thumb;
gboolean found = FALSE;
- g_mutex_lock (priv->lock);
+ g_mutex_lock (&priv->lock);
for (l = priv->thumbnailers; l && !found; l = g_list_next (l))
{
@@ -524,7 +524,7 @@ update_or_create_thumbnailer (GnomeDesktopThumbnailFactory *factory,
gnome_desktop_thumbnail_factory_add_thumbnailer (factory, thumb);
}
- g_mutex_unlock (priv->lock);
+ g_mutex_unlock (&priv->lock);
}
@@ -536,7 +536,7 @@ remove_thumbnailer (GnomeDesktopThumbnailFactory *factory,
GList *l;
Thumbnailer *thumb;
- g_mutex_lock (priv->lock);
+ g_mutex_lock (&priv->lock);
for (l = priv->thumbnailers; l; l = g_list_next (l))
{
@@ -554,7 +554,7 @@ remove_thumbnailer (GnomeDesktopThumbnailFactory *factory,
}
}
- g_mutex_unlock (priv->lock);
+ g_mutex_unlock (&priv->lock);
}
@@ -657,7 +657,7 @@ external_thumbnailers_disabled_all_changed_cb (GSettings *set
const gchar *key,
GnomeDesktopThumbnailFactory *factory)
{
- g_mutex_lock (factory->priv->lock);
+ g_mutex_lock (&factory->priv->lock);
factory->priv->disabled = g_settings_get_boolean (factory->priv->settings, "disable-all");
if (factory->priv->disabled) {
@@ -669,7 +669,7 @@ external_thumbnailers_disabled_all_changed_cb (GSettings *set
gnome_desktop_thumbnail_factory_load_thumbnailers (factory);
}
- g_mutex_unlock (factory->priv->lock);
+ g_mutex_unlock (&factory->priv->lock);
}
static void
@@ -677,14 +677,14 @@ external_thumbnailers_disabled_changed_cb (GSettings *setting
const gchar *key,
GnomeDesktopThumbnailFactory *factory)
{
- g_mutex_lock (factory->priv->lock);
+ g_mutex_lock (&factory->priv->lock);
if (factory->priv->disabled)
return;
g_strfreev (factory->priv->disabled_types);
factory->priv->disabled_types = g_settings_get_strv (factory->priv->settings, "disable");
- g_mutex_unlock (factory->priv->lock);
+ g_mutex_unlock (&factory->priv->lock);
}
@@ -770,10 +770,7 @@ gnome_desktop_thumbnail_factory_finalize (GObject *object)
gnome_desktop_thumbnail_factory_finalize_scripts (factory);
- if (factory->priv->lock) {
- g_mutex_free (factory->priv->lock);
- factory->priv->lock = NULL;
- }
+ g_mutex_clear (&factory->priv->lock);
if (G_OBJECT_CLASS (parent_class)->finalize)
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
@@ -785,7 +782,7 @@ gnome_desktop_thumbnail_factory_init (GnomeDesktopThumbnailFactory *factory)
{
factory->priv = GNOME_DESKTOP_THUMBNAIL_FACTORY_GET_PRIVATE (factory);
factory->priv->size = GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL;
- factory->priv->lock = g_mutex_new ();
+ g_mutex_init (&factory->priv->lock);
gnome_desktop_thumbnail_factory_init_scripts (factory);
@@ -1174,9 +1171,9 @@ gnome_desktop_thumbnail_factory_generate_from_script (GnomeDesktopThumbnailFacto
size = 256;
script = NULL;
- g_mutex_lock (factory->priv->lock);
+ g_mutex_lock (&factory->priv->lock);
script = gnome_desktop_thumbnail_factory_get_script (factory, mime_type);
- g_mutex_unlock (factory->priv->lock);
+ g_mutex_unlock (&factory->priv->lock);
if (script == NULL) {
*error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, "No script");
diff --git a/gthumb/gth-async-task.c b/gthumb/gth-async-task.c
index 4ff17f7..100ad9e 100644
--- a/gthumb/gth-async-task.c
+++ b/gthumb/gth-async-task.c
@@ -45,7 +45,7 @@ struct _GthAsyncTaskPrivate {
GthAsyncReadyFunc after_func;
gpointer user_data;
GDestroyNotify user_data_destroy_func;
- GMutex *data_mutex;
+ GMutex data_mutex;
guint progress_event;
gboolean cancelled;
gboolean terminated;
@@ -72,7 +72,7 @@ gth_async_task_finalize (GObject *object)
if ((self->priv->user_data != NULL) && (self->priv->user_data_destroy_func))
(*self->priv->user_data_destroy_func) (self->priv->user_data);
- g_mutex_free (self->priv->data_mutex);
+ g_mutex_clear (&self->priv->data_mutex);
G_OBJECT_CLASS (gth_async_task_parent_class)->finalize (object);
}
@@ -94,11 +94,11 @@ update_progress (gpointer data)
gboolean cancelled;
double progress;
- g_mutex_lock (self->priv->data_mutex);
+ g_mutex_lock (&self->priv->data_mutex);
terminated = self->priv->terminated;
cancelled = self->priv->cancelled;
progress = self->priv->progress;
- g_mutex_unlock (self->priv->data_mutex);
+ g_mutex_unlock (&self->priv->data_mutex);
if (terminated) {
GError *error = NULL;
@@ -135,9 +135,9 @@ exec_task (gpointer user_data)
result = self->priv->exec_func (self, self->priv->user_data);
- g_mutex_lock (self->priv->data_mutex);
+ g_mutex_lock (&self->priv->data_mutex);
self->priv->terminated = TRUE;
- g_mutex_unlock (self->priv->data_mutex);
+ g_mutex_unlock (&self->priv->data_mutex);
return result;
}
@@ -150,10 +150,10 @@ gth_async_task_exec (GthTask *task)
self = GTH_ASYNC_TASK (task);
- g_mutex_lock (self->priv->data_mutex);
+ g_mutex_lock (&self->priv->data_mutex);
self->priv->terminated = FALSE;
self->priv->cancelled = FALSE;
- g_mutex_unlock (self->priv->data_mutex);
+ g_mutex_unlock (&self->priv->data_mutex);
if (self->priv->before_func != NULL)
self->priv->before_func (self, self->priv->user_data);
@@ -173,9 +173,9 @@ gth_async_task_cancelled (GthTask *task)
self = GTH_ASYNC_TASK (task);
- g_mutex_lock (self->priv->data_mutex);
+ g_mutex_lock (&self->priv->data_mutex);
self->priv->cancelled = TRUE;
- g_mutex_unlock (self->priv->data_mutex);
+ g_mutex_unlock (&self->priv->data_mutex);
}
@@ -301,7 +301,7 @@ gth_async_task_init (GthAsyncTask *self)
self->priv->cancelled = FALSE;
self->priv->terminated = FALSE;
self->priv->progress_event = 0;
- self->priv->data_mutex = g_mutex_new ();
+ g_mutex_init (&self->priv->data_mutex);
self->priv->user_data = NULL;
self->priv->user_data_destroy_func = NULL;
}
@@ -330,14 +330,14 @@ gth_async_task_set_data (GthAsyncTask *self,
gboolean *cancelled,
double *progress)
{
- g_mutex_lock (self->priv->data_mutex);
+ g_mutex_lock (&self->priv->data_mutex);
if (terminated != NULL)
self->priv->terminated = *terminated;
if (cancelled != NULL)
self->priv->cancelled = *cancelled;
if (progress != NULL)
self->priv->progress = *progress;
- g_mutex_unlock (self->priv->data_mutex);
+ g_mutex_unlock (&self->priv->data_mutex);
}
@@ -347,12 +347,12 @@ gth_async_task_get_data (GthAsyncTask *self,
gboolean *cancelled,
double *progress)
{
- g_mutex_lock (self->priv->data_mutex);
+ g_mutex_lock (&self->priv->data_mutex);
if (terminated != NULL)
*terminated = self->priv->terminated;
if (cancelled != NULL)
*cancelled = self->priv->cancelled;
if (progress != NULL)
*progress = self->priv->progress;
- g_mutex_unlock (self->priv->data_mutex);
+ g_mutex_unlock (&self->priv->data_mutex);
}
diff --git a/gthumb/gth-hook.c b/gthumb/gth-hook.c
index 4afb301..6122c9c 100644
--- a/gthumb/gth-hook.c
+++ b/gthumb/gth-hook.c
@@ -50,7 +50,7 @@ typedef struct {
typedef struct {
GHookList *list;
int n_args;
- GMutex *mutex;
+ GMutex mutex;
} GthHook;
@@ -59,7 +59,7 @@ gth_hook_free (GthHook *hook)
{
g_hook_list_clear (hook->list);
g_free (hook->list);
- g_mutex_free (hook->mutex);
+ g_mutex_clear (&hook->mutex);
g_free (hook);
}
@@ -97,7 +97,7 @@ gth_hook_register (const char *name,
hook->list = g_new (GHookList, 1);
g_hook_list_init (hook->list, sizeof (GthHookCallback));
hook->n_args = n_args;
- hook->mutex = g_mutex_new ();
+ g_mutex_init (&hook->mutex);
g_hash_table_insert (hooks, g_strdup (name), hook);
}
@@ -264,10 +264,10 @@ gth_hook_invoke (const char *name,
break;
}
- g_mutex_lock (hook->mutex);
+ g_mutex_lock (&hook->mutex);
if (invoke_marshaller != NULL)
g_hook_list_marshal (hook->list, TRUE, invoke_marshaller, marshal_data);
- g_mutex_unlock (hook->mutex);
+ g_mutex_unlock (&hook->mutex);
g_free (marshal_data);
}
@@ -380,10 +380,10 @@ gth_hook_invoke_get (const char *name,
break;
}
- g_mutex_lock (hook->mutex);
+ g_mutex_lock (&hook->mutex);
if (invoke_marshaller != NULL)
g_hook_list_marshal (hook->list, TRUE, invoke_marshaller, marshal_data);
- g_mutex_unlock (hook->mutex);
+ g_mutex_unlock (&hook->mutex);
value = marshal_data[hook->n_args];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]