vcl/source/window/layout.cxx |   27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

New commits:
commit e8d93ae128f7947e64eb8c849b4af9c54c9dd7a5
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu Apr 1 10:31:27 2021 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Thu Apr 1 13:37:53 2021 +0200

    Resolves: tdf#141258 turn scrollbars on/off once per layout loop
    
    in this scenario the vertical scrollbar is turned off, then turned on
    back to its original state but the off/on triggers another layout
    loop later which does the same thing. Turn on/off just once per loop
    so only one state change can occur so new layout is only triggered
    if the state really changes.
    
    Change-Id: I5736264a74723a15034e5fb467262dca6c0f283c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113447
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index ccdcc923117f..d5e5839583fd 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -1905,31 +1905,36 @@ void VclScrolledWindow::doSetAllocation(const Size 
&rAllocation, bool bRetryOnFa
 
     tools::Long nAvailHeight = rAllocation.Height() - 2 * m_nBorderWidth;
     tools::Long nAvailWidth = rAllocation.Width() - 2 * m_nBorderWidth;
+
     // vert. ScrollBar
+    bool bShowVScroll;
     if (GetStyle() & WB_AUTOVSCROLL)
-    {
-        m_pVScroll->Show(nAvailHeight < aChildReq.Height());
-    }
-    else if (m_pVScroll->IsVisible() != bool(GetStyle() & WB_VSCROLL))
-        m_pVScroll->Show((GetStyle() & WB_VSCROLL) != 0);
+        bShowVScroll = nAvailHeight < aChildReq.Height();
+    else
+        bShowVScroll = (GetStyle() & WB_VSCROLL) != 0;
 
-    if (m_pVScroll->IsVisible())
+    if (bShowVScroll)
         nAvailWidth -= getLayoutRequisition(*m_pVScroll).Width();
 
     // horz. ScrollBar
+    bool bShowHScroll;
     if (GetStyle() & WB_AUTOHSCROLL)
     {
-        bool bShowHScroll = nAvailWidth < aChildReq.Width();
-        m_pHScroll->Show(bShowHScroll);
+        bShowHScroll = nAvailWidth < aChildReq.Width();
 
         if (bShowHScroll)
             nAvailHeight -= getLayoutRequisition(*m_pHScroll).Height();
 
         if (GetStyle() & WB_AUTOVSCROLL)
-            m_pVScroll->Show(nAvailHeight < aChildReq.Height());
+            bShowVScroll = nAvailHeight < aChildReq.Height();
     }
-    else if (m_pHScroll->IsVisible() != bool(GetStyle() & WB_HSCROLL))
-        m_pHScroll->Show((GetStyle() & WB_HSCROLL) != 0);
+    else
+        bShowHScroll = (GetStyle() & WB_HSCROLL) != 0;
+
+    if (m_pHScroll->IsVisible() != bShowHScroll)
+        m_pHScroll->Show(bShowHScroll);
+    if (m_pVScroll->IsVisible() != bShowVScroll)
+        m_pVScroll->Show(bShowVScroll);
 
     Size aInnerSize(rAllocation);
     aInnerSize.AdjustWidth(-2 * m_nBorderWidth);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to