kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

Blame SOURCES/0001-rhbz-1057977-avoid-use-of-invalidated-pointers.patch

f085be
From 35f78e48582caa691a855101a0d661985ba067bb Mon Sep 17 00:00:00 2001
f085be
From: David Tardon <dtardon@redhat.com>
f085be
Date: Wed, 5 Feb 2014 10:55:25 +0100
f085be
Subject: [PATCH] rhbz#1057977 avoid use of invalidated pointers
f085be
f085be
Change-Id: Ib81f79da696b5e8002f5a2ddcf160903231dc3f1
f085be
---
f085be
 include/vcl/outdev.hxx     |  6 +++++
f085be
 vcl/source/gdi/outdev3.cxx | 59 +++++++++++++++++++++++++++++++++++++++++-----
f085be
 2 files changed, 59 insertions(+), 6 deletions(-)
f085be
f085be
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
f085be
index 047a79d..4f157b7 100644
f085be
--- a/include/vcl/outdev.hxx
f085be
+++ b/include/vcl/outdev.hxx
f085be
@@ -547,9 +547,15 @@ protected:
f085be
                         OutputDevice();
f085be
 
f085be
 private:
f085be
+    typedef void ( OutputDevice::* FontUpdateHandler_t )( bool );
f085be
+
f085be
     SAL_DLLPRIVATE                OutputDevice( const OutputDevice& rOutDev );
f085be
     SAL_DLLPRIVATE OutputDevice&  operator =( const OutputDevice& rOutDev );
f085be
 
f085be
+    SAL_DLLPRIVATE void         ImplClearFontData( bool bNewFontLists );
f085be
+    SAL_DLLPRIVATE void         ImplRefreshFontData( bool bNewFontLists );
f085be
+    SAL_DLLPRIVATE static void  ImplUpdateFontDataForAllFrames( FontUpdateHandler_t pHdl, bool bNewFontLists );
f085be
+
f085be
 public:
f085be
     virtual             ~OutputDevice();
f085be
 
f085be
diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
f085be
index afe06f7..d789eb9 100644
f085be
--- a/vcl/source/gdi/outdev3.cxx
f085be
+++ b/vcl/source/gdi/outdev3.cxx
f085be
@@ -156,7 +156,7 @@ static void ImplRotatePos( long nOriginX, long nOriginY, long& rX, long& rY,
f085be
     }
f085be
 }
f085be
 
f085be
-void OutputDevice::ImplUpdateFontData( bool bNewFontLists )
f085be
+void OutputDevice::ImplClearFontData( const bool bNewFontLists )
f085be
 {
f085be
     // the currently selected logical font is no longer needed
f085be
     if ( mpFontEntry )
f085be
@@ -207,6 +207,38 @@ void OutputDevice::ImplUpdateFontData( bool bNewFontLists )
f085be
                         delete mpFontList;
f085be
                     if( mpFontCache && mpFontCache != pSVData->maGDIData.mpScreenFontCache )
f085be
                         delete mpFontCache;
f085be
+                    mpFontList = 0;
f085be
+                    mpFontCache = 0;
f085be
+                }
f085be
+            }
f085be
+        }
f085be
+    }
f085be
+
f085be
+    // also update child windows if needed
f085be
+    if ( GetOutDevType() == OUTDEV_WINDOW )
f085be
+    {
f085be
+        Window* pChild = ((Window*)this)->mpWindowImpl->mpFirstChild;
f085be
+        while ( pChild )
f085be
+        {
f085be
+            pChild->ImplClearFontData( true );
f085be
+            pChild = pChild->mpWindowImpl->mpNext;
f085be
+        }
f085be
+    }
f085be
+}
f085be
+
f085be
+void OutputDevice::ImplRefreshFontData( const bool bNewFontLists )
f085be
+{
f085be
+//    if ( GetOutDevType() == OUTDEV_PRINTER || mpPDFWriter )
f085be
+    {
f085be
+        ImplSVData* pSVData = ImplGetSVData();
f085be
+
f085be
+        if ( bNewFontLists )
f085be
+        {
f085be
+            // we need a graphics
f085be
+            if ( ImplGetGraphics() )
f085be
+            {
f085be
+                if( mpPDFWriter )
f085be
+                {
f085be
                     mpFontList = pSVData->maGDIData.mpScreenFontList->Clone( true, true );
f085be
                     mpFontCache = new ImplFontCache( sal_False );
f085be
                 }
f085be
@@ -227,16 +259,24 @@ void OutputDevice::ImplUpdateFontData( bool bNewFontLists )
f085be
         Window* pChild = ((Window*)this)->mpWindowImpl->mpFirstChild;
f085be
         while ( pChild )
f085be
         {
f085be
-            pChild->ImplUpdateFontData( true );
f085be
+            pChild->ImplRefreshFontData( true );
f085be
             pChild = pChild->mpWindowImpl->mpNext;
f085be
         }
f085be
     }
f085be
 }
f085be
 
f085be
+void OutputDevice::ImplUpdateFontData( bool bNewFontLists )
f085be
+{
f085be
+    ImplClearFontData( bNewFontLists );
f085be
+    ImplRefreshFontData( bNewFontLists );
f085be
+}
f085be
+
f085be
 void OutputDevice::ImplUpdateAllFontData( bool bNewFontLists )
f085be
 {
f085be
     ImplSVData* pSVData = ImplGetSVData();
f085be
 
f085be
+    ImplUpdateFontDataForAllFrames( &OutputDevice::ImplClearFontData, bNewFontLists );
f085be
+
f085be
     // clear global font lists to have them updated
f085be
     pSVData->maGDIData.mpScreenFontCache->Invalidate();
f085be
     if ( bNewFontLists )
f085be
@@ -255,16 +295,23 @@ void OutputDevice::ImplUpdateAllFontData( bool bNewFontLists )
f085be
         }
f085be
     }
f085be
 
f085be
+    ImplUpdateFontDataForAllFrames( &OutputDevice::ImplRefreshFontData, bNewFontLists );
f085be
+}
f085be
+
f085be
+void OutputDevice::ImplUpdateFontDataForAllFrames( const FontUpdateHandler_t pHdl, const bool bNewFontLists )
f085be
+{
f085be
+    ImplSVData* const pSVData = ImplGetSVData();
f085be
+
f085be
     // update all windows
f085be
     Window* pFrame = pSVData->maWinData.mpFirstFrame;
f085be
     while ( pFrame )
f085be
     {
f085be
-        pFrame->ImplUpdateFontData( bNewFontLists );
f085be
+        ( pFrame->*pHdl )( bNewFontLists );
f085be
 
f085be
         Window* pSysWin = pFrame->mpWindowImpl->mpFrameData->mpFirstOverlap;
f085be
         while ( pSysWin )
f085be
         {
f085be
-            pSysWin->ImplUpdateFontData( bNewFontLists );
f085be
+            ( pSysWin->*pHdl )( bNewFontLists );
f085be
             pSysWin = pSysWin->mpWindowImpl->mpNextOverlap;
f085be
         }
f085be
 
f085be
@@ -275,7 +322,7 @@ void OutputDevice::ImplUpdateAllFontData( bool bNewFontLists )
f085be
     VirtualDevice* pVirDev = pSVData->maGDIData.mpFirstVirDev;
f085be
     while ( pVirDev )
f085be
     {
f085be
-        pVirDev->ImplUpdateFontData( bNewFontLists );
f085be
+        ( pVirDev->*pHdl )( bNewFontLists );
f085be
         pVirDev = pVirDev->mpNext;
f085be
     }
f085be
 
f085be
@@ -283,7 +330,7 @@ void OutputDevice::ImplUpdateAllFontData( bool bNewFontLists )
f085be
     Printer* pPrinter = pSVData->maGDIData.mpFirstPrinter;
f085be
     while ( pPrinter )
f085be
     {
f085be
-        pPrinter->ImplUpdateFontData( bNewFontLists );
f085be
+        ( pPrinter->*pHdl )( bNewFontLists );
f085be
         pPrinter = pPrinter->mpNext;
f085be
     }
f085be
 }
f085be
-- 
f085be
1.8.5.3
f085be