gtk: Fix "children left" warning with fatal warnings
authorBastien Nocera <hadess@hadess.net>
Tue, 14 Mar 2023 15:00:47 +0000 (16:00 +0100)
committerBastien Nocera <hadess@hadess.net>
Tue, 14 Mar 2023 15:45:59 +0000 (16:45 +0100)
When fatal warnings were turned on, the developer would never see which
widgets were left as children to the widget that triggered the warning as
those were printed in separate g_warning calls.

Print a single warning with all the info so runs with fatal warnings
aren't left without any info.

gtk/gtkwidget.c

index 702f9a72c16dc4b25bd1499da8d6c00052f7883d..974e12617222fa8b02abfcc18e8243d2bfb30bdd 100644 (file)
@@ -7637,14 +7637,20 @@ gtk_widget_finalize (GObject *object)
   if (_gtk_widget_get_first_child (widget) != NULL)
     {
       GtkWidget *child;
-      g_warning ("Finalizing %s %p, but it still has children left:",
-                 gtk_widget_get_name (widget), widget);
+      GString *s;
+
+      s = g_string_new (NULL);
+      g_string_append_printf (s, "Finalizing %s %p, but it still has children left:",
+                              gtk_widget_get_name (widget), widget);
       for (child = _gtk_widget_get_first_child (widget);
            child != NULL;
            child = _gtk_widget_get_next_sibling (child))
         {
-          g_warning ("   - %s %p", gtk_widget_get_name (child), child);
+          g_string_append_printf (s, "\n   - %s %p",
+                                  gtk_widget_get_name (child), child);
         }
+      g_warning ("%s", s->str);
+      g_string_free (s, TRUE);
     }
 
   if (g_object_is_floating (object))