]> Pileus Git - ~andy/gtk/commitdiff
Warn when calling gtk_window_parse_geometry() on an empty window
authorOwen W. Taylor <otaylor@fishsoup.net>
Sun, 10 Oct 2010 02:29:20 +0000 (22:29 -0400)
committerOwen W. Taylor <otaylor@fishsoup.net>
Mon, 11 Oct 2010 18:06:03 +0000 (14:06 -0400)
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

index 571484eb9ea436186de82887732a2f0fa26465b5..0c6dbe1f25e4a523a8033af10ed5dad1c59d69d6 100644 (file)
@@ -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);