vcl/source/window/brdwin.cxx |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

New commits:
commit 31700036e517691d154701f4b8aeecb85cde607f
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Tue Jan 18 10:35:22 2022 +0100
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Tue Jan 18 12:23:49 2022 +0100

    Avoid endless recursion in ImplSmallBorderWindowView::Init
    
    At least on macOS, some `make screenshot` tests crashed for me due to 
endless
    recursion, like the processing of modules/swriter/ui/converttexttable.ui in
    CppunitTest_sw_dialogs_test for LO_TEST_LOCALE=gu:
    
    [...]
    > ImplSmallBorderWindowView::Init at vcl/source/window/brdwin.cxx:557:20
    > ImplBorderWindow::Resize at vcl/source/window/brdwin.cxx:1736
    > vcl::Window::queue_resize at vcl/source/window/window2.cxx:1351:28
    > ImplSmallBorderWindowView::Init at vcl/source/window/brdwin.cxx:557:20
    > ImplBorderWindow::Resize at vcl/source/window/brdwin.cxx:1736
    > vcl::Window::queue_resize at vcl/source/window/window2.cxx:1351:28
    > ImplSmallBorderWindowView::Init at vcl/source/window/brdwin.cxx:557:20
    [...]
    
    where in the calls to ImplSmallBorderWindowView::Init, nWidth=24 and 
nHeight=31,
    as well as mnLeftBorder=6, mnTopBorder=6, and mnBottomBorder=6 remain 
stable,
    but mnRightBorder keeps changing between 6 and 5.
    
    This appears to be caused by instabilities in the
    ImplLogicToDevicePixel and ImplDevicePixelToLogic calculations in
    OutputDevice::GetNativeControlRegion (vcl/source/outdev/nativecontrols.cxx),
    which can be avoided when we compute a hypothetical native control region 
from
    aCtrolRegion that includes the borders, and only remove the borders from the
    resulting aBounds and aContent.  (The code to shrink aCtrlRegion prior to
    calling GetNativeControlRegion had been introduced with
    27be8a263eddb54cb6b66cc0f832bfd02016a694 "KDE4 fix edit box borders".)
    
    Change-Id: I88c0d15ae7045a6888768226ca4d5fdd66bb41ca
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128549
    Reviewed-by: Jan-Marek Glogowski <glo...@fbihome.de>
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>
    Tested-by: Jenkins

diff --git a/vcl/source/window/brdwin.cxx b/vcl/source/window/brdwin.cxx
index 95d508ce3597..c003ed17b78d 100644
--- a/vcl/source/window/brdwin.cxx
+++ b/vcl/source/window/brdwin.cxx
@@ -474,15 +474,23 @@ void ImplSmallBorderWindowView::Init( OutputDevice* pDev, 
tools::Long nWidth, to
             if( mbNWFBorder )
             {
                 ImplControlValue aControlValue;
-                Size aMinSize( mnWidth - mnLeftBorder - mnRightBorder, 
mnHeight - mnTopBorder - mnBottomBorder );
+                Size aMinSize( mnWidth, mnHeight );
                 if( aMinSize.Width() < 10 ) aMinSize.setWidth( 10 );
                 if( aMinSize.Height() < 10 ) aMinSize.setHeight( 10 );
-                tools::Rectangle aCtrlRegion( Point(mnLeftBorder, 
mnTopBorder), aMinSize );
+                tools::Rectangle aCtrlRegion( Point(), aMinSize );
                 tools::Rectangle aBounds, aContent;
                 if( pWin->GetNativeControlRegion( aCtrlType, aCtrlPart, 
aCtrlRegion,
                                                   ControlState::ENABLED, 
aControlValue,
                                                   aBounds, aContent ) )
                 {
+                    aBounds.AdjustLeft(mnLeftBorder);
+                    aBounds.AdjustRight(-mnRightBorder);
+                    aBounds.AdjustTop(mnTopBorder);
+                    aBounds.AdjustBottom(-mnBottomBorder);
+                    aContent.AdjustLeft(mnLeftBorder);
+                    aContent.AdjustRight(-mnRightBorder);
+                    aContent.AdjustTop(mnTopBorder);
+                    aContent.AdjustBottom(-mnBottomBorder);
                     mnLeftBorder    = aContent.Left() - aBounds.Left();
                     mnRightBorder   = aBounds.Right() - aContent.Right();
                     mnTopBorder     = aContent.Top() - aBounds.Top();

Reply via email to