After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 766530 - scrolledwindow: Fix typo in get_preferred_height calculation
scrolledwindow: Fix typo in get_preferred_height calculation
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkScrolledWindow
3.21.x
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2016-05-16 19:12 UTC by Debarshi Ray
Modified: 2016-05-17 05:41 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
scrolledwindow: Fix typo in get_preferred_height calculation (1.66 KB, patch)
2016-05-16 19:26 UTC, Debarshi Ray
committed Details | Review

Description Debarshi Ray 2016-05-16 19:12:35 UTC
The following commit introduced a typo in the get_preferred_height calculation code.

commit 55196a705f00564a44647bfc97981db0a783369a
Author: Tadej Borovšak <tadeboro@gmail.com>
Date:   Mon Oct 18 00:21:39 2010 -0400

    Add GtkScrollable interface
    
    The GtkScrollable interface provides "hadjustment" and "vadjustment"
    properties that are used by GtkScrolledWindow. It replaces
    the ::set_scroll_adjustment signal. The scrollable interface
    also has ::min-display-width/height properties that can be
    used to control the minimally visible part inside a scrolled window.

Particularly, the second else block of this chunk:

@@ -2043,9 +2044,20 @@ gtk_scrolled_window_get_preferred_size (GtkWidget      *widget,
            }
          else
            {
-             /* Always ask for at least enough to fit the scrollbars */
-             minimum_req.height += hscrollbar_requisition.height;
-             natural_req.height += hscrollbar_requisition.height;
+             gint min_display_height = 
+               gtk_scrollable_get_min_display_height (GTK_SCROLLABLE (child));
+
+             if (min_display_height > 0)
+               {
+                 minimum_req.height += min_display_height;
+                 natural_req.height += min_display_height;
+                 extra_height = -1;
+               }
+             else
+               {
+                 minimum_req.height += vscrollbar_requisition.height;
+                 natural_req.height += vscrollbar_requisition.height;
+               }
            }
        }
     }

Interestingly, this chunk seems to have fixed an earlier typo:

@@ -2064,14 +2076,14 @@ gtk_scrolled_window_get_preferred_size (GtkWidget      *widget,
     {
       minimum_req.height = MAX (minimum_req.height, vscrollbar_requisition.height);
       natural_req.height = MAX (natural_req.height, vscrollbar_requisition.height);
-      if (!extra_height || priv->vscrollbar_policy == GTK_POLICY_ALWAYS)
+      if (!extra_width || priv->vscrollbar_policy == GTK_POLICY_ALWAYS)
        extra_width = scrollbar_spacing + vscrollbar_requisition.width;
     }
Comment 1 Debarshi Ray 2016-05-16 19:26:36 UTC
Created attachment 328008 [details] [review]
scrolledwindow: Fix typo in get_preferred_height calculation
Comment 2 Matthias Clasen 2016-05-16 21:59:21 UTC
Review of attachment 328008 [details] [review]:

Looks right to me. I guess we'll find out if anything breaks.
Comment 3 Debarshi Ray 2016-05-17 05:41:38 UTC
Comment on attachment 328008 [details] [review]
scrolledwindow: Fix typo in get_preferred_height calculation

Thanks for the review. Pushed to master.