From 519d7587117269773c1bd85887779b80fca04b81 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Sat, 9 Oct 2010 22:29:20 -0400 Subject: [PATCH] Warn when calling gtk_window_parse_geometry() on an empty window gtk_window_parse_geometry() gets the size of the window in order to interpret the position of the window; calling it before, say, calling gtk_widget_show_all() on a window is a subtle trap, so add a warning in the case we can easily detect. https://bugzilla.gnome.org/show_bug.cgi?id=631794 --- gtk/gtkwindow.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 571484eb9e..0c6dbe1f25 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -8820,6 +8820,7 @@ gtk_window_parse_geometry (GtkWindow *window, { gint result, x = 0, y = 0; guint w, h; + GtkWidget *child; GdkGravity grav; gboolean size_set, pos_set; GdkScreen *screen; @@ -8827,6 +8828,12 @@ gtk_window_parse_geometry (GtkWindow *window, g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE); g_return_val_if_fail (geometry != NULL, FALSE); + child = gtk_bin_get_child (GTK_BIN (window)); + if (!child || !gtk_widget_get_visible (child)) + g_warning ("gtk_window_parse_geometry() called on a window with no " + "visible children; the window should be set up before " + "gtk_window_parse_geometry() is called."); + screen = gtk_window_check_screen (window); result = gtk_XParseGeometry (geometry, &x, &y, &w, &h);