[eog] Use new GLib threading API



commit b5f61d90d0478378cf7cf21bf5ade9eded0ae9f2
Author: Felix Riemann <friemann gnome org>
Date:   Sun Feb 19 14:13:40 2012 +0100

    Use new GLib threading API
    
    https://bugzilla.gnome.org/show_bug.cgi?id=670185

 src/eog-image-private.h |    2 +-
 src/eog-image.c         |   39 ++++++++++++++++++---------------------
 src/eog-jobs.c          |    8 +++++---
 src/eog-list-store.c    |   14 +++++++-------
 4 files changed, 31 insertions(+), 32 deletions(-)
---
diff --git a/src/eog-image-private.h b/src/eog-image-private.h
index bbe1916..3af4e90 100644
--- a/src/eog-image-private.h
+++ b/src/eog-image-private.h
@@ -81,7 +81,7 @@ struct _EogImagePrivate {
 
 	gchar            *collate_key;
 
-	GMutex           *status_mutex;
+	GMutex            status_mutex;
 
 	gboolean          cancel_loading;
 	guint             data_ref_count;
diff --git a/src/eog-image.c b/src/eog-image.c
index 9aa334b..a2d6c6b 100644
--- a/src/eog-image.c
+++ b/src/eog-image.c
@@ -187,10 +187,7 @@ eog_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);
@@ -300,7 +297,7 @@ eog_image_init (EogImage *img)
 	img->priv->height = -1;
 	img->priv->modified = FALSE;
 	img->priv->file_is_changed = FALSE;
-	img->priv->status_mutex = g_mutex_new ();
+	g_mutex_init (&img->priv->status_mutex);
 	img->priv->status = EOG_IMAGE_STATUS_UNKNOWN;
         img->priv->metadata_status = EOG_IMAGE_METADATA_NOT_READ;
 	img->priv->is_monitored = FALSE;
@@ -539,12 +536,12 @@ eog_image_size_prepared (GdkPixbufLoader *loader,
 
 	img = EOG_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))
@@ -855,12 +852,12 @@ eog_image_set_exif_data (EogImage *img, EogMetadataReader *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 = eog_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;
@@ -1385,9 +1382,9 @@ eog_image_get_pixbuf (EogImage *img)
 
 	g_return_val_if_fail (EOG_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);
@@ -2139,13 +2136,13 @@ eog_image_cancel_load (EogImage *img)
 
 	priv = img->priv;
 
-	g_mutex_lock (priv->status_mutex);
+	g_mutex_lock (&priv->status_mutex);
 
 	if (priv->status == EOG_IMAGE_STATUS_LOADING) {
 		priv->cancel_loading = TRUE;
 	}
 
-	g_mutex_unlock (priv->status_mutex);
+	g_mutex_unlock (&priv->status_mutex);
 }
 
 #ifdef HAVE_EXIF
@@ -2159,12 +2156,12 @@ eog_image_get_exif_info (EogImage *img)
 
 	priv = img->priv;
 
-	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);
 
 	return data;
 }
@@ -2190,9 +2187,9 @@ eog_image_get_xmp_info (EogImage *img)
 	EogImagePrivate *priv;
  	priv = img->priv;
 
- 	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;
@@ -2401,7 +2398,7 @@ eog_image_iter_advance (EogImage *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);
@@ -2413,7 +2410,7 @@ eog_image_iter_advance (EogImage *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));
@@ -2474,10 +2471,10 @@ eog_image_start_animation (EogImage *img)
 	if (!eog_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/eog-jobs.c b/src/eog-jobs.c
index d7978c6..7bae56a 100644
--- a/src/eog-jobs.c
+++ b/src/eog-jobs.c
@@ -64,7 +64,9 @@ static void eog_job_transform_run (EogJob *ejob);
 
 static void eog_job_init (EogJob *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 @@ eog_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 (eog_job_parent_class)->dispose) (object);
diff --git a/src/eog-list-store.c b/src/eog-list-store.c
index 0e07297..7e5c3f8 100644
--- a/src/eog-list-store.c
+++ b/src/eog-list-store.c
@@ -39,7 +39,7 @@ struct _EogListStorePrivate {
 	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
@@ -70,7 +70,7 @@ eog_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 (eog_list_store_parent_class)->dispose (object);
 }
@@ -160,7 +160,7 @@ eog_list_store_init (EogListStore *self)
 	self->priv->busy_image = eog_list_store_get_icon ("image-loading");
 	self->priv->missing_image = eog_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),
 						 eog_list_store_compare_func,
@@ -802,12 +802,12 @@ eog_list_store_remove_thumbnail_job (EogListStore *store,
 			    -1);
 
 	if (job != NULL) {
-		g_mutex_lock (store->priv->mutex);
+		g_mutex_lock (&store->priv->mutex);
 		eog_job_queue_remove_job (job);
 		gtk_list_store_set (GTK_LIST_STORE (store), iter,
 				    EOG_LIST_STORE_EOG_JOB, NULL,
 				    -1);
-		g_mutex_unlock (store->priv->mutex);
+		g_mutex_unlock (&store->priv->mutex);
 	}
 
 
@@ -836,12 +836,12 @@ eog_list_store_add_thumbnail_job (EogListStore *store, GtkTreeIter *iter)
 			  G_CALLBACK (eog_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,
 			    EOG_LIST_STORE_EOG_JOB, job,
 			    -1);
 	eog_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);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]