summaryrefslogtreecommitdiff
path: root/libdocument
diff options
context:
space:
mode:
Diffstat (limited to 'libdocument')
-rw-r--r--libdocument/ev-document.c34
-rw-r--r--libdocument/ev-mapping-list.c2
2 files changed, 9 insertions, 27 deletions
diff --git a/libdocument/ev-document.c b/libdocument/ev-document.c
index 667f89f1..fc45830d 100644
--- a/libdocument/ev-document.c
+++ b/libdocument/ev-document.c
@@ -69,8 +69,8 @@ static gchar *_ev_document_get_page_label (EvDocument *document,
static EvDocumentInfo *_ev_document_get_info (EvDocument *document);
static gboolean _ev_document_support_synctex (EvDocument *document);
-GMutex *ev_doc_mutex = NULL;
-GMutex *ev_fc_mutex = NULL;
+static GMutex ev_doc_mutex;
+static GMutex ev_fc_mutex;
G_DEFINE_ABSTRACT_TYPE (EvDocument, ev_document, G_TYPE_OBJECT)
@@ -160,58 +160,40 @@ ev_document_class_init (EvDocumentClass *klass)
g_object_class->finalize = ev_document_finalize;
}
-GMutex *
-ev_document_get_doc_mutex (void)
-{
- if (ev_doc_mutex == NULL) {
- ev_doc_mutex = g_mutex_new ();
- }
- return ev_doc_mutex;
-}
-
void
ev_document_doc_mutex_lock (void)
{
- g_mutex_lock (ev_document_get_doc_mutex ());
+ g_mutex_lock (&ev_doc_mutex);
}
void
ev_document_doc_mutex_unlock (void)
{
- g_mutex_unlock (ev_document_get_doc_mutex ());
+ g_mutex_unlock (&ev_doc_mutex);
}
gboolean
ev_document_doc_mutex_trylock (void)
{
- return g_mutex_trylock (ev_document_get_doc_mutex ());
-}
-
-GMutex *
-ev_document_get_fc_mutex (void)
-{
- if (ev_fc_mutex == NULL) {
- ev_fc_mutex = g_mutex_new ();
- }
- return ev_fc_mutex;
+ return g_mutex_trylock (&ev_doc_mutex);
}
void
ev_document_fc_mutex_lock (void)
{
- g_mutex_lock (ev_document_get_fc_mutex ());
+ g_mutex_lock (&ev_fc_mutex);
}
void
ev_document_fc_mutex_unlock (void)
{
- g_mutex_unlock (ev_document_get_fc_mutex ());
+ g_mutex_unlock (&ev_fc_mutex);
}
gboolean
ev_document_fc_mutex_trylock (void)
{
- return g_mutex_trylock (ev_document_get_fc_mutex ());
+ return g_mutex_trylock (&ev_fc_mutex);
}
/**
diff --git a/libdocument/ev-mapping-list.c b/libdocument/ev-mapping-list.c
index 6c670158..44628b09 100644
--- a/libdocument/ev-mapping-list.c
+++ b/libdocument/ev-mapping-list.c
@@ -136,7 +136,7 @@ ev_mapping_list_unref (EvMappingList *mapping_list)
g_return_if_fail (mapping_list != NULL);
g_return_if_fail (mapping_list->ref_count > 0);
- if (g_atomic_int_exchange_and_add (&mapping_list->ref_count, -1) - 1 == 0) {
+ if (g_atomic_int_add (&mapping_list->ref_count, -1) - 1 == 0) {
g_list_foreach (mapping_list->list,
(GFunc)mapping_list_free_foreach,
mapping_list->data_destroy_func);