From b477d24222b6561d2ca0b7eff9a34d774d248b5f Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 21 Apr 2010 19:23:27 +0000 Subject: [PATCH] (trunk gtk) add gtr_warn_if_fail(), a portability wrapper for systems too old for g_warn_if_fail() --- gtk/tr-core.c | 2 +- gtk/util.h | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gtk/tr-core.c b/gtk/tr-core.c index b1571fa78..44e3680b1 100644 --- a/gtk/tr-core.c +++ b/gtk/tr-core.c @@ -1213,7 +1213,7 @@ tr_core_remove_torrent_from_id( TrCore * core, int id, gboolean deleteFiles ) /* remove the torrent */ tr_torrent_set_remove_flag( gtor, TRUE ); - g_warn_if_fail( G_OBJECT( gtor )->ref_count == 1 ); + gtr_warn_if_fail( G_OBJECT( gtor )->ref_count == 1 ); g_object_unref( G_OBJECT( gtor ) ); /* remove the last refcount */ } } diff --git a/gtk/util.h b/gtk/util.h index 7f686947f..0ee151701 100644 --- a/gtk/util.h +++ b/gtk/util.h @@ -14,8 +14,18 @@ #define GTR_UTIL_H #include +#include #include +/* portability wrapper around g_warn_if_fail() for older versions of glib */ +#ifdef g_warn_if_fail + #define gtr_warn_if_fail(expr) g_warn_if_fail(expr) +#else + #define gtr_warn_if_fail(expr) do { if G_LIKELY (expr) ; else \ + g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "%s:%d func(): %s: invariant failed: %s", \ + __FILE__, __LINE__, G_STRFUNC, #expr ); } while(0) +#endif + /* macro to shut up "unused parameter" warnings */ #ifndef UNUSED #define UNUSED G_GNUC_UNUSED -- 2.40.0