mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-22 18:22:11 +01:00
gobject: Add single function to check G_ENABLE_DIAGNOSTIC
It was duplicated, and racing too
This commit is contained in:
parent
ad2041a292
commit
5c7d249419
@ -1771,20 +1771,29 @@ g_object_real_dispose (GObject *object)
|
|||||||
g_datalist_id_set_data (&object->qdata, quark_closure_array, NULL);
|
g_datalist_id_set_data (&object->qdata, quark_closure_array, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
g_diagnostic_is_enabled (void)
|
||||||
|
{
|
||||||
|
static const char *g_enable_diagnostic = NULL;
|
||||||
|
|
||||||
|
if (g_once_init_enter_pointer (&g_enable_diagnostic))
|
||||||
|
{
|
||||||
|
const gchar *value = g_getenv ("G_ENABLE_DIAGNOSTIC");
|
||||||
|
|
||||||
|
if (value == NULL)
|
||||||
|
value = "0";
|
||||||
|
|
||||||
|
g_once_init_leave_pointer (&g_enable_diagnostic, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_enable_diagnostic[0] == '1';
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef G_ENABLE_DEBUG
|
#ifdef G_ENABLE_DEBUG
|
||||||
static gboolean
|
static gboolean
|
||||||
floating_check (GObject *object)
|
floating_check (GObject *object)
|
||||||
{
|
{
|
||||||
static const char *g_enable_diagnostic = NULL;
|
if (g_diagnostic_is_enabled ())
|
||||||
|
|
||||||
if (G_UNLIKELY (g_enable_diagnostic == NULL))
|
|
||||||
{
|
|
||||||
g_enable_diagnostic = g_getenv ("G_ENABLE_DIAGNOSTIC");
|
|
||||||
if (g_enable_diagnostic == NULL)
|
|
||||||
g_enable_diagnostic = "0";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_enable_diagnostic[0] == '1')
|
|
||||||
return g_object_is_floating (object);
|
return g_object_is_floating (object);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -2082,21 +2091,10 @@ static void
|
|||||||
maybe_issue_property_deprecation_warning (const GParamSpec *pspec)
|
maybe_issue_property_deprecation_warning (const GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
static GHashTable *already_warned_table;
|
static GHashTable *already_warned_table;
|
||||||
static const gchar *enable_diagnostic;
|
|
||||||
static GMutex already_warned_lock;
|
static GMutex already_warned_lock;
|
||||||
gboolean already;
|
gboolean already;
|
||||||
|
|
||||||
if (g_once_init_enter_pointer (&enable_diagnostic))
|
if (!g_diagnostic_is_enabled ())
|
||||||
{
|
|
||||||
const gchar *value = g_getenv ("G_ENABLE_DIAGNOSTIC");
|
|
||||||
|
|
||||||
if (!value)
|
|
||||||
value = "0";
|
|
||||||
|
|
||||||
g_once_init_leave_pointer (&enable_diagnostic, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (enable_diagnostic[0] == '0')
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* We hash only on property names: this means that we could end up in
|
/* We hash only on property names: this means that we could end up in
|
||||||
|
Loading…
x
Reference in New Issue
Block a user