vcl/source/window/window.cxx |   25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

New commits:
commit b8381e0f275d1d1a6b4a737437905ace71f1fe3a
Author: Michael Meeks <michael.me...@collabora.com>
Date:   Tue Mar 28 10:35:50 2017 +0100

    Attempted fix for mirrored geometry crasher.
    
    Only plausible cause is pWindow->GetParent() being null, while
    we have a pParent which has to be valid.
    
    
http://crashreport.libreoffice.org/stats/crash_details/6161398d-17b6-4a93-aa70-a559efa07868
    
    Code was initially introduced in this form:
            commit 4716735ba7d0ad133ff018481f94d6b4f201bbd9
            Author: Stephan Schäfer <s...@openoffice.org>
            Date:   Thu Sep 19 15:46:19 2002 +0000
    
            #103362# improve positioning and resizing of system windows
    
    No public report, sadly.  And modified by
    
    commit fba46c6efd08d50fee92cc11546f3ed253a57af8
    Author: Chris Sherlock <chris.sherloc...@gmail.com>
    Date:   Mon Feb 3 16:46:04 2014 +1100
    
        fdo#74424 Use Window::GetOutDev() to access ImplReMirrored()
    
        Part of the decoupling of Window from OutputDevice. We now get
        he Window's OutputDevice instance and manipulate this. Do not rely
        on the inherited function.
    
    where the GetParent()/pWindow->GetParent() problem surfaces
    
    Change-Id: Ia261028a4719525135e3fe4b00074427c1d9df6c
    Reviewed-on: https://gerrit.libreoffice.org/35796
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Michael Meeks <michael.me...@collabora.com>
    Tested-by: Michael Meeks <michael.me...@collabora.com>
    (cherry picked from commit d93b8268da982ad26db9e03156ce9b89f3410486)
    Reviewed-on: https://gerrit.libreoffice.org/35828
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Tested-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 472b0f67c403..722486cc490f 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -2750,7 +2750,7 @@ void Window::setPosSizePixel( long nX, long nY,
         mpWindowImpl->mbDefSize = false;
 
     // The top BorderWindow is the window which is to be positioned
-    vcl::Window* pWindow = this;
+    VclPtr<vcl::Window> pWindow = this;
     while ( pWindow->mpWindowImpl->mpBorderWindow )
         pWindow = pWindow->mpWindowImpl->mpBorderWindow;
 
@@ -2767,7 +2767,8 @@ void Window::setPosSizePixel( long nX, long nY,
             nHeight = pWindow->mnOutHeight;
 
         sal_uInt16 nSysFlags=0;
-        vcl::Window *pParent = GetParent();
+        VclPtr<vcl::Window> pParent = GetParent();
+        VclPtr<vcl::Window> pWinParent = pWindow->GetParent();
 
         if( nFlags & PosSizeFlags::Width )
             nSysFlags |= SAL_FRAME_POSSIZE_WIDTH;
@@ -2776,9 +2777,9 @@ void Window::setPosSizePixel( long nX, long nY,
         if( nFlags & PosSizeFlags::X )
         {
             nSysFlags |= SAL_FRAME_POSSIZE_X;
-            if( pParent && (pWindow->GetStyle() & WB_SYSTEMCHILDWINDOW) )
+            if( pWinParent && (pWindow->GetStyle() & WB_SYSTEMCHILDWINDOW) )
             {
-                nX += pParent->mnOutOffX;
+                nX += pWinParent->mnOutOffX;
             }
             if( pParent && pParent->ImplIsAntiparallel() )
             {
@@ -2793,9 +2794,9 @@ void Window::setPosSizePixel( long nX, long nY,
         {
             // --- RTL ---  make sure the old right aligned position is not 
changed
             //              system windows will always grow to the right
-            if ( pParent )
+            if ( pWinParent )
             {
-                OutputDevice *pParentOutDev = pParent->GetOutDev();
+                OutputDevice *pParentOutDev = pWinParent->GetOutDev();
                 if( pParentOutDev->HasMirroredGraphics() )
                 {
                     long myWidth = nOldWidth;
@@ -2805,13 +2806,13 @@ void Window::setPosSizePixel( long nX, long nY,
                         myWidth = nWidth;
                     nFlags |= PosSizeFlags::X;
                     nSysFlags |= SAL_FRAME_POSSIZE_X;
-                    nX = 
pParent->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nX - 
mpWindowImpl->mpFrame->GetUnmirroredGeometry().nLeftDecoration +
-                        
pParent->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nWidth - myWidth - 1 - 
mpWindowImpl->mpFrame->GetUnmirroredGeometry().nX;
+                    nX = 
pWinParent->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nX - 
mpWindowImpl->mpFrame->GetUnmirroredGeometry().nLeftDecoration +
+                        
pWinParent->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nWidth - myWidth - 1 
- mpWindowImpl->mpFrame->GetUnmirroredGeometry().nX;
                     if(!(nFlags & PosSizeFlags::Y))
                     {
                         nFlags |= PosSizeFlags::Y;
                         nSysFlags |= SAL_FRAME_POSSIZE_Y;
-                        nY = mpWindowImpl->mpFrame->GetUnmirroredGeometry().nY 
- pWindow->GetParent()->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nY -
+                        nY = mpWindowImpl->mpFrame->GetUnmirroredGeometry().nY 
- pWinParent->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nY -
                             
mpWindowImpl->mpFrame->GetUnmirroredGeometry().nTopDecoration;
                     }
                 }
@@ -2820,9 +2821,9 @@ void Window::setPosSizePixel( long nX, long nY,
         if( nFlags & PosSizeFlags::Y )
         {
             nSysFlags |= SAL_FRAME_POSSIZE_Y;
-            if( pParent && (pWindow->GetStyle() & WB_SYSTEMCHILDWINDOW) )
+            if( pWinParent && (pWindow->GetStyle() & WB_SYSTEMCHILDWINDOW) )
             {
-                nY += pParent->mnOutOffY;
+                nY += pWinParent->mnOutOffY;
             }
         }
 
@@ -2831,7 +2832,7 @@ void Window::setPosSizePixel( long nX, long nY,
             // check for min/max client size and adjust size accordingly
             // otherwise it may happen that the resize event is ignored, i.e. 
the old size remains
             // unchanged but ImplHandleResize() is called with the wrong size
-            SystemWindow *pSystemWindow = dynamic_cast< SystemWindow* >( 
pWindow );
+            SystemWindow *pSystemWindow = dynamic_cast< SystemWindow* >( 
pWindow.get() );
             if( pSystemWindow )
             {
                 Size aMinSize = pSystemWindow->GetMinOutputSizePixel();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to