mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-28 02:20:04 +01:00
gmessages: do implicit GPrivate initialisation
Initialise the GPrivate implicitly at the site of first use rather than explicitly from the thread initialisation function.
This commit is contained in:
parent
90679997ec
commit
4596dfbc75
@ -108,6 +108,7 @@ static GLogLevelFlags g_log_always_fatal = G_LOG_FATAL_MASK;
|
|||||||
static GPrintFunc glib_print_func = NULL;
|
static GPrintFunc glib_print_func = NULL;
|
||||||
static GPrintFunc glib_printerr_func = NULL;
|
static GPrintFunc glib_printerr_func = NULL;
|
||||||
static GPrivate g_log_depth;
|
static GPrivate g_log_depth;
|
||||||
|
static gboolean g_log_depth_initialised;
|
||||||
static GLogLevelFlags g_log_msg_prefix = G_LOG_LEVEL_ERROR | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_DEBUG;
|
static GLogLevelFlags g_log_msg_prefix = G_LOG_LEVEL_ERROR | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_DEBUG;
|
||||||
static GLogFunc default_log_func = g_log_default_handler;
|
static GLogFunc default_log_func = g_log_default_handler;
|
||||||
static gpointer default_log_data = NULL;
|
static gpointer default_log_data = NULL;
|
||||||
@ -512,12 +513,12 @@ g_logv (const gchar *log_domain,
|
|||||||
test_level = 1 << i;
|
test_level = 1 << i;
|
||||||
if (log_level & test_level)
|
if (log_level & test_level)
|
||||||
{
|
{
|
||||||
guint depth = GPOINTER_TO_UINT (g_private_get (&g_log_depth));
|
|
||||||
GLogDomain *domain;
|
GLogDomain *domain;
|
||||||
GLogFunc log_func;
|
GLogFunc log_func;
|
||||||
GLogLevelFlags domain_fatal_mask;
|
GLogLevelFlags domain_fatal_mask;
|
||||||
gpointer data = NULL;
|
gpointer data = NULL;
|
||||||
gboolean masquerade_fatal = FALSE;
|
gboolean masquerade_fatal = FALSE;
|
||||||
|
guint depth;
|
||||||
|
|
||||||
if (was_fatal)
|
if (was_fatal)
|
||||||
test_level |= G_LOG_FLAG_FATAL;
|
test_level |= G_LOG_FLAG_FATAL;
|
||||||
@ -526,6 +527,12 @@ g_logv (const gchar *log_domain,
|
|||||||
|
|
||||||
/* check recursion and lookup handler */
|
/* check recursion and lookup handler */
|
||||||
g_mutex_lock (&g_messages_lock);
|
g_mutex_lock (&g_messages_lock);
|
||||||
|
if (!g_log_depth_initialised)
|
||||||
|
{
|
||||||
|
g_private_init (&g_log_depth, NULL);
|
||||||
|
g_log_depth_initialised = TRUE;
|
||||||
|
}
|
||||||
|
depth = GPOINTER_TO_UINT (g_private_get (&g_log_depth));
|
||||||
domain = g_log_find_domain_L (log_domain ? log_domain : "");
|
domain = g_log_find_domain_L (log_domain ? log_domain : "");
|
||||||
if (depth)
|
if (depth)
|
||||||
test_level |= G_LOG_FLAG_RECURSION;
|
test_level |= G_LOG_FLAG_RECURSION;
|
||||||
@ -1214,7 +1221,6 @@ g_printf_string_upper_bound (const gchar *format,
|
|||||||
void
|
void
|
||||||
_g_messages_thread_init_nomessage (void)
|
_g_messages_thread_init_nomessage (void)
|
||||||
{
|
{
|
||||||
g_private_init (&g_log_depth, NULL);
|
|
||||||
g_messages_prefixed_init ();
|
g_messages_prefixed_init ();
|
||||||
g_debug_init ();
|
g_debug_init ();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user