From 083520cea68aaff0e17346e7f7dace06063abf8b Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Thu, 8 Oct 2015 21:41:24 +0200 Subject: [PATCH] Remove compat code for pre-2.32 glib Signed-off-by: Sebastian Ramacher --- README | 2 +- config.mk | 2 +- zathura/glib-compat.h | 24 ------------------------ zathura/main.c | 3 --- zathura/render.c | 29 ++++++++++++++--------------- 5 files changed, 16 insertions(+), 44 deletions(-) delete mode 100644 zathura/glib-compat.h diff --git a/README b/README index 2f4cb0f..f061d03 100644 --- a/README +++ b/README @@ -6,7 +6,7 @@ girara user interface library and several document libraries. Requirements ------------ gtk3 -glib (>= 2.28) +glib (>= 2.32) girara (>= 0.2.4) sqlite3 (optional, >= 3.5.9) check (for tests) diff --git a/config.mk b/config.mk index 92b3016..45d1b47 100644 --- a/config.mk +++ b/config.mk @@ -22,7 +22,7 @@ GIRARA_MIN_VERSION = 0.2.4 GIRARA_PKG_CONFIG_NAME = girara-gtk3 # glib GLIB_VERSION_CHECK ?= 1 -GLIB_MIN_VERSION = 2.28 +GLIB_MIN_VERSION = 2.32 GLIB_PKG_CONFIG_NAME = glib-2.0 # GTK GTK_VERSION_CHECK ?= 1 diff --git a/zathura/glib-compat.h b/zathura/glib-compat.h deleted file mode 100644 index 3e98dae..0000000 --- a/zathura/glib-compat.h +++ /dev/null @@ -1,24 +0,0 @@ -/* See LICENSE file for license and copyright information */ - -#ifndef GLIB_COMPAT_H -#define GLIB_COMPAT_H - -#include - -/* GStaticMutex is deprecated starting with glib 2.32 and got replaced with - * GMutex */ -#if GLIB_CHECK_VERSION(2, 32, 0) -#define mutex GMutex -#define mutex_init(m) g_mutex_init((m)) -#define mutex_lock(m) g_mutex_lock((m)) -#define mutex_unlock(m) g_mutex_unlock((m)) -#define mutex_free(m) g_mutex_clear((m)) -#else -#define mutex GStaticMutex -#define mutex_init(m) g_static_mutex_init((m)) -#define mutex_lock(m) g_static_mutex_lock((m)) -#define mutex_unlock(m) g_static_mutex_unlock((m)) -#define mutex_free(m) g_static_mutex_free((m)) -#endif - -#endif diff --git a/zathura/main.c b/zathura/main.c index c94f535..ade5f07 100644 --- a/zathura/main.c +++ b/zathura/main.c @@ -28,9 +28,6 @@ main(int argc, char* argv[]) textdomain(GETTEXT_PACKAGE); /* init gtk */ -#if !GLIB_CHECK_VERSION(2, 31, 0) - g_thread_init(NULL); -#endif #if !GTK_CHECK_VERSION(3, 6, 0) gdk_threads_init(); #endif diff --git a/zathura/render.c b/zathura/render.c index e291289..5bab6c9 100644 --- a/zathura/render.c +++ b/zathura/render.c @@ -4,7 +4,6 @@ #include #include #include -#include "glib-compat.h" #include "render.h" #include "adjustment.h" @@ -34,7 +33,7 @@ static bool page_cache_is_full(ZathuraRenderer* renderer, bool* result); /* private data for ZathuraRenderer */ typedef struct private_s { GThreadPool* pool; /**< Pool of threads */ - mutex mutex; /**< Render lock */ + GMutex mutex; /**< Render lock */ volatile bool about_to_close; /**< Render thread is to be freed */ /** @@ -68,7 +67,7 @@ typedef struct request_private_s { zathura_page_t* page; gint64 last_view_time; girara_list_t* active_jobs; - mutex jobs_mutex; + GMutex jobs_mutex; } request_private_t; #define GET_PRIVATE(obj) \ @@ -103,7 +102,7 @@ zathura_renderer_init(ZathuraRenderer* renderer) priv->pool = g_thread_pool_new(render_job, renderer, 1, TRUE, NULL); priv->about_to_close = false; g_thread_pool_set_sort_function(priv->pool, render_thread_sort, NULL); - mutex_init(&priv->mutex); + g_mutex_init(&priv->mutex); /* recolor */ priv->recolor.enabled = false; @@ -161,7 +160,7 @@ renderer_finalize(GObject* object) if (priv->pool != NULL) { g_thread_pool_free(priv->pool, TRUE, TRUE); } - mutex_free(&(priv->mutex)); + g_mutex_free(&(priv->mutex)); free(priv->page_cache.cache); girara_list_free(priv->requests); @@ -265,7 +264,7 @@ zathura_render_request_new(ZathuraRenderer* renderer, zathura_page_t* page) priv->renderer = g_object_ref(renderer); priv->page = page; priv->active_jobs = girara_list_new(); - mutex_init(&priv->jobs_mutex); + g_mutex_init(&priv->jobs_mutex); /* register the request with the renderer */ renderer_register_request(renderer, request); @@ -299,7 +298,7 @@ render_request_finalize(GObject* object) girara_error("This should not happen!"); } girara_list_free(priv->active_jobs); - mutex_free(&priv->jobs_mutex); + g_mutex_free(&priv->jobs_mutex); G_OBJECT_CLASS(zathura_render_request_parent_class)->finalize(object); } @@ -407,7 +406,7 @@ zathura_renderer_lock(ZathuraRenderer* renderer) g_return_if_fail(ZATHURA_IS_RENDERER(renderer)); private_t* priv = GET_PRIVATE(renderer); - mutex_lock(&priv->mutex); + g_mutex_lock(&priv->mutex); } void @@ -416,7 +415,7 @@ zathura_renderer_unlock(ZathuraRenderer* renderer) g_return_if_fail(ZATHURA_IS_RENDERER(renderer)); private_t* priv = GET_PRIVATE(renderer); - mutex_unlock(&priv->mutex); + g_mutex_unlock(&priv->mutex); } void @@ -435,7 +434,7 @@ zathura_render_request(ZathuraRenderRequest* request, gint64 last_view_time) g_return_if_fail(ZATHURA_IS_RENDER_REQUEST(request)); request_private_t* request_priv = REQUEST_GET_PRIVATE(request); - mutex_lock(&request_priv->jobs_mutex); + g_mutex_lock(&request_priv->jobs_mutex); bool unfinished_jobs = false; /* check if there are any active jobs left */ @@ -462,7 +461,7 @@ zathura_render_request(ZathuraRenderRequest* request, gint64 last_view_time) g_thread_pool_push(priv->pool, job, NULL); } - mutex_unlock(&request_priv->jobs_mutex); + g_mutex_unlock(&request_priv->jobs_mutex); } void @@ -471,11 +470,11 @@ zathura_render_request_abort(ZathuraRenderRequest* request) g_return_if_fail(ZATHURA_IS_RENDER_REQUEST(request)); request_private_t* request_priv = REQUEST_GET_PRIVATE(request); - mutex_lock(&request_priv->jobs_mutex); + g_mutex_lock(&request_priv->jobs_mutex); GIRARA_LIST_FOREACH(request_priv->active_jobs, render_job_t*, iter, job) job->aborted = true; GIRARA_LIST_FOREACH_END(request_priv->active_jobs, render_job_t*, iter, job); - mutex_unlock(&request_priv->jobs_mutex); + g_mutex_unlock(&request_priv->jobs_mutex); } void @@ -494,9 +493,9 @@ remove_job_and_free(render_job_t* job) { request_private_t* request_priv = REQUEST_GET_PRIVATE(job->request); - mutex_lock(&request_priv->jobs_mutex); + g_mutex_lock(&request_priv->jobs_mutex); girara_list_remove(request_priv->active_jobs, job); - mutex_unlock(&request_priv->jobs_mutex); + g_mutex_unlock(&request_priv->jobs_mutex); g_object_unref(job->request); g_free(job);