summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2014-02-05 10:55:25 +0100
committerAndras Timar <andras.timar@collabora.com>2014-07-22 11:43:48 +0200
commit46b29a89a287e90ca58faf48a899cc72bed2d48c (patch)
tree0416d458d862452e056dc34227059537a78abaf7 /vcl
parentcd8495e13f7cb250bdc8d3774bbc9c208b459e7a (diff)
fdo#78598 avoid use of invalidated pointers
Change-Id: Ib81f79da696b5e8002f5a2ddcf160903231dc3f1 (cherry picked from commit 6b127d40c7d57745bc602d9ff7914392f9d3b92b) Reviewed-on: https://gerrit.libreoffice.org/10421 Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com> Tested-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/gdi/outdev3.cxx59
1 files changed, 53 insertions, 6 deletions
diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
index a36fc855f31d..a8cb7fc5e674 100644
--- a/vcl/source/gdi/outdev3.cxx
+++ b/vcl/source/gdi/outdev3.cxx
@@ -156,7 +156,7 @@ static void ImplRotatePos( long nOriginX, long nOriginY, long& rX, long& rY,
}
}
-void OutputDevice::ImplUpdateFontData( bool bNewFontLists )
+void OutputDevice::ImplClearFontData( const bool bNewFontLists )
{
// the currently selected logical font is no longer needed
if ( mpFontEntry )
@@ -207,6 +207,38 @@ void OutputDevice::ImplUpdateFontData( bool bNewFontLists )
delete mpFontList;
if( mpFontCache && mpFontCache != pSVData->maGDIData.mpScreenFontCache )
delete mpFontCache;
+ mpFontList = 0;
+ mpFontCache = 0;
+ }
+ }
+ }
+ }
+
+ // also update child windows if needed
+ if ( GetOutDevType() == OUTDEV_WINDOW )
+ {
+ Window* pChild = ((Window*)this)->mpWindowImpl->mpFirstChild;
+ while ( pChild )
+ {
+ pChild->ImplClearFontData( true );
+ pChild = pChild->mpWindowImpl->mpNext;
+ }
+ }
+}
+
+void OutputDevice::ImplRefreshFontData( const bool bNewFontLists )
+{
+// if ( GetOutDevType() == OUTDEV_PRINTER || mpPDFWriter )
+ {
+ ImplSVData* pSVData = ImplGetSVData();
+
+ if ( bNewFontLists )
+ {
+ // we need a graphics
+ if ( ImplGetGraphics() )
+ {
+ if( mpPDFWriter )
+ {
mpFontList = pSVData->maGDIData.mpScreenFontList->Clone( true, true );
mpFontCache = new ImplFontCache( sal_False );
}
@@ -227,16 +259,24 @@ void OutputDevice::ImplUpdateFontData( bool bNewFontLists )
Window* pChild = ((Window*)this)->mpWindowImpl->mpFirstChild;
while ( pChild )
{
- pChild->ImplUpdateFontData( true );
+ pChild->ImplRefreshFontData( true );
pChild = pChild->mpWindowImpl->mpNext;
}
}
}
+void OutputDevice::ImplUpdateFontData( bool bNewFontLists )
+{
+ ImplClearFontData( bNewFontLists );
+ ImplRefreshFontData( bNewFontLists );
+}
+
void OutputDevice::ImplUpdateAllFontData( bool bNewFontLists )
{
ImplSVData* pSVData = ImplGetSVData();
+ ImplUpdateFontDataForAllFrames( &OutputDevice::ImplClearFontData, bNewFontLists );
+
// clear global font lists to have them updated
pSVData->maGDIData.mpScreenFontCache->Invalidate();
if ( bNewFontLists )
@@ -255,16 +295,23 @@ void OutputDevice::ImplUpdateAllFontData( bool bNewFontLists )
}
}
+ ImplUpdateFontDataForAllFrames( &OutputDevice::ImplRefreshFontData, bNewFontLists );
+}
+
+void OutputDevice::ImplUpdateFontDataForAllFrames( const FontUpdateHandler_t pHdl, const bool bNewFontLists )
+{
+ ImplSVData* const pSVData = ImplGetSVData();
+
// update all windows
Window* pFrame = pSVData->maWinData.mpFirstFrame;
while ( pFrame )
{
- pFrame->ImplUpdateFontData( bNewFontLists );
+ ( pFrame->*pHdl )( bNewFontLists );
Window* pSysWin = pFrame->mpWindowImpl->mpFrameData->mpFirstOverlap;
while ( pSysWin )
{
- pSysWin->ImplUpdateFontData( bNewFontLists );
+ ( pSysWin->*pHdl )( bNewFontLists );
pSysWin = pSysWin->mpWindowImpl->mpNextOverlap;
}
@@ -275,7 +322,7 @@ void OutputDevice::ImplUpdateAllFontData( bool bNewFontLists )
VirtualDevice* pVirDev = pSVData->maGDIData.mpFirstVirDev;
while ( pVirDev )
{
- pVirDev->ImplUpdateFontData( bNewFontLists );
+ ( pVirDev->*pHdl )( bNewFontLists );
pVirDev = pVirDev->mpNext;
}
@@ -283,7 +330,7 @@ void OutputDevice::ImplUpdateAllFontData( bool bNewFontLists )
Printer* pPrinter = pSVData->maGDIData.mpFirstPrinter;
while ( pPrinter )
{
- pPrinter->ImplUpdateFontData( bNewFontLists );
+ ( pPrinter->*pHdl )( bNewFontLists );
pPrinter = pPrinter->mpNext;
}
}