[gtk+] Warn when calling gtk_window_parse_geometry() on an empty window



commit 519d7587117269773c1bd85887779b80fca04b81
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Sat Oct 9 22:29:20 2010 -0400

    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 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 571484e..0c6dbe1 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);



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