Add diagnostic mode
GLib has a "diagnostic mode" switch that can be checked to enable debug messages on deprecated properties and signals, as these are purely run-time constructs, and as such cannot be caught by compiler warnings. The diagnostic mode is toggled by a simple environment variable, and can be used to ease porting of application code. We can use something similar to mark deprecated virtual functions and other run-time constructs; to avoid collisions, we should use our own environment variable, CLUTTER_ENABLE_DIAGNOSTIC.
This commit is contained in:
parent
db246569b7
commit
7d4a9c6f1e
@ -3752,3 +3752,34 @@ _clutter_debug_message (const char *format, ...)
|
|||||||
_clutter_debug_messagev (format, args);
|
_clutter_debug_messagev (format, args);
|
||||||
va_end (args);
|
va_end (args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
_clutter_diagnostic_enabled (void)
|
||||||
|
{
|
||||||
|
static const char *clutter_enable_diagnostic = NULL;
|
||||||
|
|
||||||
|
if (G_UNLIKELY (clutter_enable_diagnostic == NULL))
|
||||||
|
{
|
||||||
|
clutter_enable_diagnostic = g_getenv ("CLUTTER_ENABLE_DIAGNOSTIC");
|
||||||
|
|
||||||
|
if (clutter_enable_diagnostic == NULL)
|
||||||
|
clutter_enable_diagnostic = "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
return *clutter_enable_diagnostic != '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_clutter_diagnostic_message (const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
char *fmt;
|
||||||
|
|
||||||
|
fmt = g_strconcat ("[DIAGNOSTIC]: ", format, NULL);
|
||||||
|
|
||||||
|
va_start (args, format);
|
||||||
|
g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, fmt, args);
|
||||||
|
va_end (args);
|
||||||
|
|
||||||
|
g_free (fmt);
|
||||||
|
}
|
||||||
|
@ -210,6 +210,10 @@ const gchar *_clutter_gettext (const gchar *str);
|
|||||||
|
|
||||||
gboolean _clutter_feature_init (GError **error);
|
gboolean _clutter_feature_init (GError **error);
|
||||||
|
|
||||||
|
/* Diagnostic mode */
|
||||||
|
gboolean _clutter_diagnostic_enabled (void);
|
||||||
|
void _clutter_diagnostic_message (const char *fmt, ...);
|
||||||
|
|
||||||
/* Picking code */
|
/* Picking code */
|
||||||
guint _clutter_pixel_to_id (guchar pixel[4]);
|
guint _clutter_pixel_to_id (guchar pixel[4]);
|
||||||
void _clutter_id_to_color (guint id,
|
void _clutter_id_to_color (guint id,
|
||||||
|
Loading…
Reference in New Issue
Block a user