mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-29 04:14:11 +02:00
gobject: add GOBJECT_IF_DEBUG macro for debugging gobjects and gsignals.
historically, DEBUG_CODE(gtype.c) and IF_DEBUG(gobject.c, gsignal.c) macros are used to support debugging messages about object bookkeeping and signal emission. DEBUG_CODE has never been used in gtype.c. IF_DEBUG, when used, must be accompanied by an extra #ifdef G_ENABLE_DEBUG. this is cumbersome. this patch add a new macro GOBJECT_IF_DEBUG based on DEBUG_CODE as a replacement for both DEBUG_CODE and IF_DEBUG. https://bugzilla.gnome.org/show_bug.cgi?id=729914
This commit is contained in:
@@ -24,6 +24,24 @@
|
||||
#include "gboxed.h"
|
||||
#include "gclosure.h"
|
||||
|
||||
/*< private >
|
||||
* GOBJECT_IF_DEBUG:
|
||||
* @debug_type: Currently only OBJECTS and SIGNALS are supported.
|
||||
* @code_block: Custom debug code.
|
||||
*
|
||||
* A convenience macro for debugging GObject.
|
||||
* This macro is only used internally.
|
||||
*/
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
#define GOBJECT_IF_DEBUG(debug_type, code_block) \
|
||||
G_STMT_START { \
|
||||
if (_g_type_debug_flags & G_TYPE_DEBUG_ ## debug_type) \
|
||||
{ code_block; } \
|
||||
} G_STMT_END
|
||||
#else /* !G_ENABLE_DEBUG */
|
||||
#define GOBJECT_IF_DEBUG(debug_type, code_block)
|
||||
#endif /* G_ENABLE_DEBUG */
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
extern GTypeDebugFlags _g_type_debug_flags;
|
||||
|
Reference in New Issue
Block a user