sw/source/core/view/pagepreviewlayout.cxx |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

New commits:
commit 4dbf1e6897453b998e3f5460612f871bb2eded63
Author: Caolán McNamara <caol...@redhat.com>
Date:   Wed Mar 9 15:51:41 2016 +0000

    Resolves: tdf#82781 avoid dereferencing invalid iterators
    
    when using print preview with cursor on 2nd page which consists solely of
    hidden text with show hiddle text enabled.
    
    inner mrParentViewShell.Paint can invalidate iterators, as later
    detected with the mbNewLayoutDuringPaint flag but we dereference
    for the purposes of drawing the shadow before we get there.
    
    easiest thing seems to be to just grab the bits of info we want before the
    inner paint occurs.
    
    Change-Id: I09c9b06449db440b7beba7de9e71c239ee64f6ca
    (cherry picked from commit 4eb5f363ed9a3181a817f12d5ec49eede13b9c9c)
    Reviewed-on: https://gerrit.libreoffice.org/23092
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Björn Michaelsen <bjoern.michael...@canonical.com>

diff --git a/sw/source/core/view/pagepreviewlayout.cxx 
b/sw/source/core/view/pagepreviewlayout.cxx
index 05519c5..9994983 100644
--- a/sw/source/core/view/pagepreviewlayout.cxx
+++ b/sw/source/core/view/pagepreviewlayout.cxx
@@ -1092,7 +1092,9 @@ bool SwPagePreviewLayout::Paint(vcl::RenderContext& 
rRenderContext, const Rectan
         Rectangle aPxPaintRect = pOutputDev->LogicToPixel( aPageRect );
         if ( aPxOutRect.IsOver( aPxPaintRect) )
         {
-            if ( (*aPageIter)->pPage->IsEmptyPage() )
+            const SwPageFrame* pPage = (*aPageIter)->pPage;
+
+            if (pPage->IsEmptyPage())
             {
                 const Color aRetouche( 
mrParentViewShell.Imp()->GetRetoucheColor() );
                 if( pOutputDev->GetFillColor() != aRetouche )
@@ -1120,16 +1122,20 @@ bool SwPagePreviewLayout::Paint(vcl::RenderContext& 
rRenderContext, const Rectan
             }
             else
             {
+                const bool bIsLeftShadowed = pPage->IsLeftShadowNeeded();
+                const bool bIsRightShadowed = pPage->IsRightShadowNeeded();
+
                 mrParentViewShell.maVisArea = aPageRect;
                 aPxPaintRect.Intersection( aPxOutRect );
                 Rectangle aPaintRect = pOutputDev->PixelToLogic( aPxPaintRect 
);
                 mrParentViewShell.Paint(rRenderContext, aPaintRect);
+
                 // --> OD 2007-08-15 #i80691#
                 // paint page border and shadow
                 {
                     SwRect aPageBorderRect;
                     SwPageFrame::GetBorderAndShadowBoundRect( SwRect( 
aPageRect ), &mrParentViewShell, &rRenderContext, aPageBorderRect,
-                        (*aPageIter)->pPage->IsLeftShadowNeeded(), 
(*aPageIter)->pPage->IsRightShadowNeeded(), true );
+                        bIsLeftShadowed, bIsRightShadowed, true );
                     const vcl::Region aDLRegion(aPageBorderRect.SVRect());
                     mrParentViewShell.DLPrePaint2(aDLRegion);
                     SwPageFrame::PaintBorderAndShadow( aPageRect, 
&mrParentViewShell, true, false, true );
@@ -1144,11 +1150,10 @@ bool SwPagePreviewLayout::Paint(vcl::RenderContext& 
rRenderContext, const Rectan
                 break;
             }
 
-            if ( (*aPageIter)->pPage->GetPhyPageNum() == mnSelectedPageNum )
+            if (pPage->GetPhyPageNum() == mnSelectedPageNum)
             {
                 _PaintSelectMarkAtPage(rRenderContext, *aPageIter);
             }
-
         }
     }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to