1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 17:17:31 +00:00

(trunk gtk) add gtr_warn_if_fail(), a portability wrapper for systems too old for g_warn_if_fail()

This commit is contained in:
Charles Kerr 2010-04-21 19:23:27 +00:00
parent 25103d5198
commit b477d24222
2 changed files with 11 additions and 1 deletions

View file

@ -1213,7 +1213,7 @@ tr_core_remove_torrent_from_id( TrCore * core, int id, gboolean deleteFiles )
/* remove the torrent */ /* remove the torrent */
tr_torrent_set_remove_flag( gtor, TRUE ); 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 */ g_object_unref( G_OBJECT( gtor ) ); /* remove the last refcount */
} }
} }

View file

@ -14,8 +14,18 @@
#define GTR_UTIL_H #define GTR_UTIL_H
#include <sys/types.h> #include <sys/types.h>
#include <glib.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
/* 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 */ /* macro to shut up "unused parameter" warnings */
#ifndef UNUSED #ifndef UNUSED
#define UNUSED G_GNUC_UNUSED #define UNUSED G_GNUC_UNUSED