Print a warning if GTK_DEBUG is set but gtk isn't built with G_ENABLE_DEBUG
authorChristoph Reiter <reiter.christoph@gmail.com>
Wed, 2 Oct 2019 19:35:20 +0000 (21:35 +0200)
committerChristoph Reiter <reiter.christoph@gmail.com>
Wed, 2 Oct 2019 19:35:20 +0000 (21:35 +0200)
G_ENABLE_DEBUG is tied to the meson builttype property, so building with "plain"
results in G_ENABLE_DEBUG not being defined and the GTK_DEBUG env var just gets ignored
for that build.

Since it can be confusing that GTK_DEBUG has no effect print a warning message instead.

See #2020. This is a port of !1109 to master

gtk/gtkmain.c

index 2d1ab71af5a61b3cc5e5f1ad169a0ea70695ce0d..7d3f43bc9b8f78d0afd9bf73bd9a0b7cba06b671 100644 (file)
@@ -605,17 +605,19 @@ do_pre_parse_initialization (void)
 
   gdk_pre_parse ();
 
-#ifdef G_ENABLE_DEBUG
   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));
       any_display_debug_flags_set = debug_flags[0].flags > 0;
+#else
+      g_warning ("GTK_DEBUG set but ignored because gtk isn't built with G_ENABLE_DEBUG");
+#endif  /* G_ENABLE_DEBUG */
       env_string = NULL;
     }
-#endif  /* G_ENABLE_DEBUG */
 
   env_string = g_getenv ("GTK_SLOWDOWN");
   if (env_string)