From 93d68270c468c5102e6dac795b4aa1ed43ba9627 Mon Sep 17 00:00:00 2001 From: Daniel Boles Date: Fri, 10 Mar 2017 20:37:27 +0000 Subject: [PATCH] =?UTF-8?q?ScrolledWindow:=20Don=E2=80=99t=20check=20if=20?= =?UTF-8?q?child=20is=20Scrollable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the child added is not a Scrollable, it gets wrapped in a ViewPort – which is. So it is impossible to end up with a non-Scrollable child. Just check we have /any/ child where needed, which is semantically nicer https://bugzilla.gnome.org/show_bug.cgi?id=778853 --- gtk/gtkscrolledwindow.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c index 7fec8b0da9..69faa06a93 100644 --- a/gtk/gtkscrolledwindow.c +++ b/gtk/gtkscrolledwindow.c @@ -1545,12 +1545,13 @@ gtk_scrolled_window_allocate (GtkCssGadget *gadget, gboolean previous_hvis; gboolean previous_vvis; guint count = 0; + GtkScrollable *scrollable_child = GTK_SCROLLABLE (child); - hscroll_policy = GTK_IS_SCROLLABLE (child) - ? gtk_scrollable_get_hscroll_policy (GTK_SCROLLABLE (child)) + hscroll_policy = scrollable_child != NULL + ? gtk_scrollable_get_hscroll_policy (scrollable_child) : GTK_SCROLL_MINIMUM; - vscroll_policy = GTK_IS_SCROLLABLE (child) - ? gtk_scrollable_get_vscroll_policy (GTK_SCROLLABLE (child)) + vscroll_policy = scrollable_child != NULL + ? gtk_scrollable_get_vscroll_policy (scrollable_child) : GTK_SCROLL_MINIMUM; /* Determine scrollbar visibility first via hfw apis */ @@ -1812,7 +1813,7 @@ gtk_scrolled_window_measure (GtkCssGadget *gadget, child = gtk_bin_get_child (bin); - if (GTK_IS_SCROLLABLE (child)) + if (child) gtk_scrollable_get_border (GTK_SCROLLABLE (child), &sborder); /* @@ -2284,7 +2285,7 @@ gtk_scrolled_window_set_hadjustment (GtkScrolledWindow *scrolled_window, gtk_scrolled_window_adjustment_value_changed (hadjustment, scrolled_window); child = gtk_bin_get_child (bin); - if (GTK_IS_SCROLLABLE (child)) + if (child) gtk_scrollable_set_hadjustment (GTK_SCROLLABLE (child), hadjustment); if (gtk_widget_should_animate (GTK_WIDGET (scrolled_window))) @@ -2352,7 +2353,7 @@ gtk_scrolled_window_set_vadjustment (GtkScrolledWindow *scrolled_window, gtk_scrolled_window_adjustment_value_changed (vadjustment, scrolled_window); child = gtk_bin_get_child (bin); - if (GTK_IS_SCROLLABLE (child)) + if (child) gtk_scrollable_set_vadjustment (GTK_SCROLLABLE (child), vadjustment); if (gtk_widget_should_animate (GTK_WIDGET (scrolled_window))) @@ -2969,8 +2970,7 @@ gtk_scrolled_window_inner_allocation (GtkWidget *widget, gtk_scrolled_window_relative_allocation (widget, rect); child = gtk_bin_get_child (GTK_BIN (widget)); - if (GTK_IS_SCROLLABLE (child) && - gtk_scrollable_get_border (GTK_SCROLLABLE (child), &border)) + if (child && gtk_scrollable_get_border (GTK_SCROLLABLE (child), &border)) { rect->x += border.left; rect->y += border.top;