diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 489d687..c50cb35 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -1495,6 +1495,11 @@ gtk_scrolled_window_size_allocate (GtkWidget     *widget,
       gboolean previous_vvis;
       guint count = 0;
 
+      /* Save previously visible state from last allocation before guessing
+       * if the scrollbars should be visible or not */
+      previous_hvis = priv->hscrollbar_visible;
+      previous_vvis = priv->vscrollbar_visible;
+
       /* In the case that both scrollbars are visible in the previous round,
        * we dont do our guess-work before hand because it's possible some
        * infinite recursion was detected (leave it up to the child scrollable
@@ -1642,9 +1647,6 @@ gtk_scrolled_window_size_allocate (GtkWidget     *widget,
 	  child_allocation.width = relative_allocation.width;
 	  child_allocation.height = relative_allocation.height;
 
-	  previous_hvis = priv->hscrollbar_visible;
-	  previous_vvis = priv->vscrollbar_visible;
-
 	  gtk_widget_size_allocate (child, &child_allocation);
 
 	  /* If, after the first iteration, the hscrollbar and the
@@ -1662,6 +1664,9 @@ gtk_scrolled_window_size_allocate (GtkWidget     *widget,
 	       */
 	      return;
 	    }
+
+	  previous_hvis = priv->hscrollbar_visible;
+	  previous_vvis = priv->vscrollbar_visible;
 	  
 	  count++;
 	}
