summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorinfirit <[email protected]>2014-05-17 15:52:02 +0200
committerinfirit <[email protected]>2014-07-24 18:05:54 +0200
commitd69408760eaa86d0532068c66c92847f2c12379c (patch)
tree7002cd155f7589524afbe198d7dcbcbbfeef06fe
parent7654cb5af09a0e7522f1fdffce5ab6b469303790 (diff)
downloadeom-d69408760eaa86d0532068c66c92847f2c12379c.tar.bz2
eom-d69408760eaa86d0532068c66c92847f2c12379c.tar.xz
Use new GLib threading API
Based on eog commit by Felix Riemann <[email protected]> Url: https://git.gnome.org/browse/eog/commit/?id=b5f61d90d0478378cf7cf21bf5ade9eded0ae9f2
-rw-r--r--src/eom-image-private.h2
-rw-r--r--src/eom-image.c39
-rw-r--r--src/eom-jobs.c8
-rw-r--r--src/eom-list-store.c14
4 files changed, 31 insertions, 32 deletions
diff --git a/src/eom-image-private.h b/src/eom-image-private.h
index cc38b40..679774e 100644
--- a/src/eom-image-private.h
+++ b/src/eom-image-private.h
@@ -80,7 +80,7 @@ struct _EomImagePrivate {
gchar *collate_key;
- GMutex *status_mutex;
+ GMutex status_mutex;
gboolean cancel_loading;
guint data_ref_count;
diff --git a/src/eom-image.c b/src/eom-image.c
index 989f365..2eac5ea 100644
--- a/src/eom-image.c
+++ b/src/eom-image.c
@@ -180,10 +180,7 @@ eom_image_dispose (GObject *object)
priv->file_type = NULL;
}
- if (priv->status_mutex) {
- g_mutex_free (priv->status_mutex);
- priv->status_mutex = NULL;
- }
+ g_mutex_clear (&priv->status_mutex);
if (priv->trans) {
g_object_unref (priv->trans);
@@ -292,7 +289,7 @@ eom_image_init (EomImage *img)
img->priv->width = -1;
img->priv->height = -1;
img->priv->modified = FALSE;
- img->priv->status_mutex = g_mutex_new ();
+ g_mutex_init (&img->priv->status_mutex);
img->priv->status = EOM_IMAGE_STATUS_UNKNOWN;
img->priv->metadata_status = EOM_IMAGE_METADATA_NOT_READ;
img->priv->is_monitored = FALSE;
@@ -531,12 +528,12 @@ eom_image_size_prepared (GdkPixbufLoader *loader,
img = EOM_IMAGE (data);
- g_mutex_lock (img->priv->status_mutex);
+ g_mutex_lock (&img->priv->status_mutex);
img->priv->width = width;
img->priv->height = height;
- g_mutex_unlock (img->priv->status_mutex);
+ g_mutex_unlock (&img->priv->status_mutex);
#ifdef HAVE_EXIF
if (img->priv->threadsafe_format && (!img->priv->autorotate || img->priv->exif))
@@ -828,12 +825,12 @@ eom_image_set_exif_data (EomImage *img, EomMetadataReader *md_reader)
priv = img->priv;
#ifdef HAVE_EXIF
- g_mutex_lock (priv->status_mutex);
+ g_mutex_lock (&priv->status_mutex);
if (priv->exif) {
exif_data_unref (priv->exif);
}
priv->exif = eom_metadata_reader_get_exif_data (md_reader);
- g_mutex_unlock (priv->status_mutex);
+ g_mutex_unlock (&priv->status_mutex);
priv->exif_chunk = NULL;
priv->exif_chunk_len = 0;
@@ -1310,9 +1307,9 @@ eom_image_get_pixbuf (EomImage *img)
g_return_val_if_fail (EOM_IS_IMAGE (img), NULL);
- g_mutex_lock (img->priv->status_mutex);
+ g_mutex_lock (&img->priv->status_mutex);
image = img->priv->image;
- g_mutex_unlock (img->priv->status_mutex);
+ g_mutex_unlock (&img->priv->status_mutex);
if (image != NULL) {
g_object_ref (image);
@@ -1873,13 +1870,13 @@ eom_image_cancel_load (EomImage *img)
priv = img->priv;
- g_mutex_lock (priv->status_mutex);
+ g_mutex_lock (&priv->status_mutex);
if (priv->status == EOM_IMAGE_STATUS_LOADING) {
priv->cancel_loading = TRUE;
}
- g_mutex_unlock (priv->status_mutex);
+ g_mutex_unlock (&priv->status_mutex);
}
gpointer
@@ -1893,12 +1890,12 @@ eom_image_get_exif_info (EomImage *img)
priv = img->priv;
#ifdef HAVE_EXIF
- g_mutex_lock (priv->status_mutex);
+ g_mutex_lock (&priv->status_mutex);
exif_data_ref (priv->exif);
data = priv->exif;
- g_mutex_unlock (priv->status_mutex);
+ g_mutex_unlock (&priv->status_mutex);
#endif
return data;
@@ -1916,9 +1913,9 @@ eom_image_get_xmp_info (EomImage *img)
priv = img->priv;
#ifdef HAVE_EXEMPI
- g_mutex_lock (priv->status_mutex);
+ g_mutex_lock (&priv->status_mutex);
data = (gpointer) xmp_copy (priv->xmp);
- g_mutex_unlock (priv->status_mutex);
+ g_mutex_unlock (&priv->status_mutex);
#endif
return data;
@@ -2112,7 +2109,7 @@ eom_image_iter_advance (EomImage *img)
if ((new_frame = gdk_pixbuf_animation_iter_advance (img->priv->anim_iter, NULL)) == TRUE)
{
- g_mutex_lock (priv->status_mutex);
+ g_mutex_lock (&priv->status_mutex);
g_object_unref (priv->image);
priv->image = gdk_pixbuf_animation_iter_get_pixbuf (priv->anim_iter);
g_object_ref (priv->image);
@@ -2124,7 +2121,7 @@ eom_image_iter_advance (EomImage *img)
priv->width = gdk_pixbuf_get_width (transformed);
priv->height = gdk_pixbuf_get_height (transformed);
}
- g_mutex_unlock (priv->status_mutex);
+ g_mutex_unlock (&priv->status_mutex);
/* Emit next frame signal so we can update the display */
g_signal_emit (img, signals[SIGNAL_NEXT_FRAME], 0,
gdk_pixbuf_animation_iter_get_delay_time (priv->anim_iter));
@@ -2185,10 +2182,10 @@ eom_image_start_animation (EomImage *img)
if (!eom_image_is_animation (img) || priv->is_playing)
return FALSE;
- g_mutex_lock (priv->status_mutex);
+ g_mutex_lock (&priv->status_mutex);
g_object_ref (priv->anim_iter);
priv->is_playing = TRUE;
- g_mutex_unlock (priv->status_mutex);
+ g_mutex_unlock (&priv->status_mutex);
g_timeout_add (gdk_pixbuf_animation_iter_get_delay_time (priv->anim_iter), private_timeout, img);
diff --git a/src/eom-jobs.c b/src/eom-jobs.c
index ee5d72b..48afc1c 100644
--- a/src/eom-jobs.c
+++ b/src/eom-jobs.c
@@ -64,7 +64,9 @@ static void eom_job_transform_run (EomJob *ejob);
static void eom_job_init (EomJob *job)
{
- job->mutex = g_mutex_new();
+ /* NOTE: We need to allocate the mutex here so the ABI stays the same when it used to use g_mutex_new */
+ job->mutex = g_malloc (sizeof (GMutex));
+ g_mutex_init (job->mutex);
job->progress = 0.0;
}
@@ -81,8 +83,8 @@ eom_job_dispose (GObject *object)
}
if (job->mutex) {
- g_mutex_free (job->mutex);
- job->mutex = NULL;
+ g_mutex_clear (job->mutex);
+ g_free (job->mutex);
}
(* G_OBJECT_CLASS (eom_job_parent_class)->dispose) (object);
diff --git a/src/eom-list-store.c b/src/eom-list-store.c
index 00de631..445c01e 100644
--- a/src/eom-list-store.c
+++ b/src/eom-list-store.c
@@ -39,7 +39,7 @@ struct _EomListStorePrivate {
gint initial_image; /* The image that should be selected firstly by the view. */
GdkPixbuf *busy_image; /* Loading image icon */
GdkPixbuf *missing_image; /* Missing image icon */
- GMutex *mutex; /* Mutex for saving the jobs in the model */
+ GMutex mutex; /* Mutex for saving the jobs in the model */
};
static void
@@ -83,7 +83,7 @@ eom_list_store_dispose (GObject *object)
store->priv->missing_image = NULL;
}
- g_mutex_free (store->priv->mutex);
+ g_mutex_clear (&store->priv->mutex);
G_OBJECT_CLASS (eom_list_store_parent_class)->dispose (object);
}
@@ -174,7 +174,7 @@ eom_list_store_init (EomListStore *self)
self->priv->busy_image = eom_list_store_get_icon ("image-loading");
self->priv->missing_image = eom_list_store_get_icon ("image-missing");
- self->priv->mutex = g_mutex_new ();
+ g_mutex_init (&self->priv->mutex);
gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (self),
eom_list_store_compare_func,
@@ -816,12 +816,12 @@ eom_list_store_remove_thumbnail_job (EomListStore *store,
-1);
if (job != NULL) {
- g_mutex_lock (store->priv->mutex);
+ g_mutex_lock (&store->priv->mutex);
eom_job_queue_remove_job (job);
gtk_list_store_set (GTK_LIST_STORE (store), iter,
EOM_LIST_STORE_EOM_JOB, NULL,
-1);
- g_mutex_unlock (store->priv->mutex);
+ g_mutex_unlock (&store->priv->mutex);
}
@@ -850,12 +850,12 @@ eom_list_store_add_thumbnail_job (EomListStore *store, GtkTreeIter *iter)
G_CALLBACK (eom_job_thumbnail_cb),
store);
- g_mutex_lock (store->priv->mutex);
+ g_mutex_lock (&store->priv->mutex);
gtk_list_store_set (GTK_LIST_STORE (store), iter,
EOM_LIST_STORE_EOM_JOB, job,
-1);
eom_job_queue_add_job (job);
- g_mutex_unlock (store->priv->mutex);
+ g_mutex_unlock (&store->priv->mutex);
g_object_unref (job);
g_object_unref (image);
}