[gnome-keyring] gck: Fix if _gck_debug was not called _gck_debugging doesn't work
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keyring] gck: Fix if _gck_debug was not called _gck_debugging doesn't work
- Date: Thu, 29 Sep 2011 14:28:41 +0000 (UTC)
commit 037872981e140ff86df03ca61b9d62527419c383
Author: Stef Walter <stefw collabora co uk>
Date: Thu Sep 29 13:06:13 2011 +0200
gck: Fix if _gck_debug was not called _gck_debugging doesn't work
* Initialize debugging in both _gck_debug and _gck_debugging
gck/gck-debug.c | 19 ++++++++++++++-----
gck/gck-debug.h | 2 ++
2 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/gck/gck-debug.c b/gck/gck-debug.c
index d301fd1..c30da4d 100644
--- a/gck/gck-debug.c
+++ b/gck/gck-debug.c
@@ -31,6 +31,7 @@
#ifdef WITH_DEBUG
+static gsize initialized_flags = 0;
static GckDebugFlags current_flags = 0;
static GDebugKey keys[] = {
@@ -56,9 +57,20 @@ _gck_debug_set_flags (const gchar *flags_string)
debug_set_flags (g_parse_debug_string (flags_string, keys, nkeys));
}
+static void
+initialize_debug_flags (void)
+{
+ if (g_once_init_enter (&initialized_flags)) {
+ _gck_debug_set_flags (g_getenv ("GCK_DEBUG"));
+ g_once_init_leave (&initialized_flags, 1);
+ }
+}
+
gboolean
_gck_debug_flag_is_set (GckDebugFlags flag)
{
+ if G_UNLIKELY (!initialized_flags)
+ initialize_debug_flags ();
return (flag & current_flags) != 0;
}
@@ -67,14 +79,11 @@ _gck_debug_message (GckDebugFlags flag,
const gchar *format,
...)
{
- static gsize initialized_flags = 0;
gchar *message;
va_list args;
- if (g_once_init_enter (&initialized_flags)) {
- _gck_debug_set_flags (g_getenv ("GCK_DEBUG"));
- g_once_init_leave (&initialized_flags, 1);
- }
+ if G_UNLIKELY (!initialized_flags)
+ initialize_debug_flags ();
va_start (args, format);
message = g_strdup_vprintf (format, args);
diff --git a/gck/gck-debug.h b/gck/gck-debug.h
index 9742033..4243292 100644
--- a/gck/gck-debug.h
+++ b/gck/gck-debug.h
@@ -40,6 +40,8 @@ void _gck_debug_message (GckDebugFlags flag,
const gchar *format,
...) G_GNUC_PRINTF (2, 3);
+void _gck_debug_init (void);
+
G_END_DECLS
#endif /* GCK_DEBUG_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]