diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2012-02-29 12:21:59 -0500 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2012-02-29 12:26:02 -0500 |
commit | 170e8712e9bfe792da29d6a3d1fb7a71fbe17336 (patch) | |
tree | b41f5cdc7f5bcddb70b10a82d089b847f0f96d9e /gtk/gtkoverlay.c | |
parent | 421d27c8581ce3a986c13577bbc7bcbc9821cd4f (diff) | |
download | gtk+-170e8712e9bfe792da29d6a3d1fb7a71fbe17336.tar.gz |
overlay: do not to set uninitialized values in the main allocation
gtk_widget_translate_coordinates() can fail in case the widget is not
realized or there's no common ancestor. Don't use the x/y values
returned by that method in that case, since their value is undefined.
Diffstat (limited to 'gtk/gtkoverlay.c')
-rw-r--r-- | gtk/gtkoverlay.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/gtk/gtkoverlay.c b/gtk/gtkoverlay.c index 331d9ee600..e27384916d 100644 --- a/gtk/gtkoverlay.c +++ b/gtk/gtkoverlay.c @@ -127,12 +127,22 @@ gtk_overlay_get_main_widget_allocation (GtkOverlay *overlay, { GtkWidget *grandchild; gint x, y; + gboolean res; grandchild = gtk_bin_get_child (GTK_BIN (main_widget)); res = gtk_widget_translate_coordinates (grandchild, main_widget, 0, 0, &x, &y); - main_alloc.x = x; - main_alloc.y = y; + if (res) + { + main_alloc.x = x; + main_alloc.y = y; + } + else + { + main_alloc.x = 0; + main_alloc.y = 0; + } + main_alloc.width = gtk_widget_get_allocated_width (grandchild); main_alloc.height = gtk_widget_get_allocated_height (grandchild); } |