[gtk/gtk-3-24: 1/2] gtk-debug: Allow interactive debug even without G_ENABLE_DEBUG




commit 0a9e2d6ed77b3a8bebdb02b3e4805ffee50428b1
Author: vanadiae <vanadiae35 gmail com>
Date:   Mon Jan 18 18:35:50 2021 +0100

    gtk-debug: Allow interactive debug even without G_ENABLE_DEBUG
    
    Currently when GTK3 is compiled without G_ENABLE_DEBUG, the inspector
    can't be opened with GTK_DEBUG=interactive because it doesn't parse
    this env var without G_ENABLE_DEBUG.
    
    Since the inspector is always good to have, this commit now always
    parses the GTK_DEBUG env var but only keep the "interactive" flag if
    G_ENABLE_DEBUG isn't defined.

 docs/reference/gtk/running.sgml |  6 +++---
 gtk/gtkmain.c                   | 11 ++++++-----
 2 files changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/docs/reference/gtk/running.sgml b/docs/reference/gtk/running.sgml
index 520a12d42d..5b136c29b4 100644
--- a/docs/reference/gtk/running.sgml
+++ b/docs/reference/gtk/running.sgml
@@ -134,9 +134,9 @@ additional environment variables.
   <title><envar>GTK_DEBUG</envar></title>
 
   <para>
-  Unless GTK+ has been configured with <option>--enable-debug=no</option>,
-  this variable can be set to a list of debug options, which cause GTK+
-  to print out different types of debugging information.
+  This variable can be set to a list of debug options, which cause GTK to
+  print out different types of debugging information. Some of these options
+  are only available when GTK has been configured with <option>--enable-debug=yes</option>.
   <variablelist>
     <varlistentry>
       <term>actions</term>
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index f7cbb342e2..ae64e1881c 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -167,7 +167,6 @@ typedef struct {
 
 DisplayDebugFlags debug_flags[N_DEBUG_DISPLAYS];
 
-#ifdef G_ENABLE_DEBUG
 static const GDebugKey gtk_debug_keys[] = {
   { "misc", GTK_DEBUG_MISC },
   { "plugsocket", GTK_DEBUG_PLUGSOCKET },
@@ -192,7 +191,6 @@ static const GDebugKey gtk_debug_keys[] = {
   { "resize", GTK_DEBUG_RESIZE },
   { "layout", GTK_DEBUG_LAYOUT }
 };
-#endif /* G_ENABLE_DEBUG */
 
 /**
  * gtk_get_major_version:
@@ -660,12 +658,15 @@ do_pre_parse_initialization (int    *argc,
   env_string = g_getenv ("GTK_DEBUG");
   if (env_string != NULL)
     {
-#ifdef G_ENABLE_DEBUG
       debug_flags[0].flags = g_parse_debug_string (env_string,
                                                    gtk_debug_keys,
                                                    G_N_ELEMENTS (gtk_debug_keys));
-#else
-      g_warning ("GTK_DEBUG set but ignored because gtk isn't built with G_ENABLE_DEBUG");
+#ifndef G_ENABLE_DEBUG
+      /* No need to print the warning for "interactive" since it's kept anyway. */
+      if (debug_flags[0].flags != GTK_DEBUG_INTERACTIVE)
+        g_warning ("GTK_DEBUG set but ignored because gtk isn't built with G_ENABLE_DEBUG");
+      /* Only keep "interactive" if not with G_ENABLE_DEBUG. */
+      debug_flags[0].flags &= GTK_DEBUG_INTERACTIVE;
 #endif  /* G_ENABLE_DEBUG */
       env_string = NULL;
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]