diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2013-10-16 18:26:46 +0200 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2013-10-16 19:11:09 +0200 |
commit | 964c5bfdc0829ab2ed113cb198abbd9298cdb67d (patch) | |
tree | 47a0d6c8d4f68e8ba95258cb82c48e5fa903d164 | |
parent | e2b8da36101ebfb9a5fe46c59c7683c8adf9f6eb (diff) |
Fix --spice-debug
If spice_util_set_debug() gets called before spice_util_get_debug(),
then the value set using spice_util_set_debug() will be overridden
by the result of g_getenv("SPICE_DEBUG") != NULL the first time
spice_util_get_debug() is called.
This causes remote-viewer --spice-debug to not enable debug as
advertised if SPICE_DEBUG is not set.
An alternate fix would have been to set debug_once.status to
G_ONCE_STATUS_READY but then we would lose the thread-safety
guarantees GOnce gives us.
-rw-r--r-- | gtk/spice-util.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gtk/spice-util.c b/gtk/spice-util.c index 4372f28..82c5faa 100644 --- a/gtk/spice-util.c +++ b/gtk/spice-util.c @@ -49,6 +49,13 @@ static GOnce debug_once = G_ONCE_INIT; **/ void spice_util_set_debug(gboolean enabled) { + /* Make sure debug_once has been initialised + * with the value of SPICE_DEBUG already, otherwise + * spice_util_get_debug() may overwrite the value + * that was just set using spice_util_set_debug() + */ + spice_util_get_debug(); + #if GLIB_CHECK_VERSION(2, 31, 0) if (enabled) { const gchar *doms = g_getenv("G_MESSAGES_DEBUG"); |