summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2016-03-24 22:20:06 +0100
committerMichael Stahl <mstahl@redhat.com>2016-03-24 23:07:32 +0100
commit99207a26df0083851ba8e23be72d5c6974f98a3b (patch)
treedbd945260838818422e933ce3c8d1edd338ee650
parent1cd0a3153db52e454818b4996a288997d60ae053 (diff)
vcl: tdf#98812: acquire reference count of WinFontInstances
... when they are inserted in WinSalGraphics::mpWinFontEntry. Not sure why one of these drops to 0 but is not removed from the WinSalGraphics when formatting this particular bugdoc. Acquiring the instances when retaining pointers to them should make the life cycle a little less insane. Change-Id: If1404f46a13736b2a226e198bdf0c3ca8e09bb38
-rw-r--r--vcl/inc/win/salgdi.h2
-rw-r--r--vcl/win/gdi/salfont.cxx12
-rw-r--r--vcl/win/gdi/winlayout.cxx6
3 files changed, 20 insertions, 0 deletions
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index a889b45dca27..ffd83ab251ad 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -219,6 +219,8 @@ private:
sal_uIntPtr mnFontKernPairCount;// Number of Kerning Pairs of the current Font
int mnPenWidth; // Linienbreite
+ LogicalFontInstance* GetWinFontEntry(int nFallbackLevel);
+
public:
HDC getHDC() const { return mhLocalDC; }
void setHDC(HDC aNew) { mhLocalDC = aNew; }
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 3278e888ecf2..0485eaf0c34d 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -1442,12 +1442,23 @@ sal_uInt16 WinSalGraphics::SetFont( FontSelectPattern* pFont, int nFallbackLevel
if( mhFonts[i] )
::DeleteFont( mhFonts[i] );
mhFonts[ i ] = 0;
+ if (mpWinFontEntry[i])
+ {
+ GetWinFontEntry(i)->mpFontCache->Release(GetWinFontEntry(i));
+ }
+ mpWinFontEntry[i] = nullptr;
+ mpWinFontData[i] = nullptr;
}
mhDefFont = 0;
return 0;
}
DBG_ASSERT( pFont->mpFontData, "WinSalGraphics mpFontData==NULL");
+ if (mpWinFontEntry[nFallbackLevel])
+ {
+ GetWinFontEntry(nFallbackLevel)->mpFontCache->Release(GetWinFontEntry(nFallbackLevel));
+ }
+ pFont->mpFontInstance->mpFontCache->Acquire(pFont->mpFontInstance);
mpWinFontEntry[ nFallbackLevel ] = reinterpret_cast<WinFontInstance*>( pFont->mpFontInstance );
mpWinFontData[ nFallbackLevel ] = static_cast<const WinFontFace*>( pFont->mpFontData );
@@ -1470,6 +1481,7 @@ sal_uInt16 WinSalGraphics::SetFont( FontSelectPattern* pFont, int nFallbackLevel
::DeleteFont( mhFonts[i] );
mhFonts[i] = 0;
}
+ // note: removing mpWinFontEntry[i] here has obviously bad effects
}
}
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index e073a01941c2..65ebbdd4b152 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -1362,6 +1362,7 @@ WinLayout::WinLayout(HDC hDC, const WinFontFace& rWFD, WinFontInstance& rWFE, bo
mrWinFontData( rWFD ),
mrWinFontEntry(rWFE)
{
+ assert(mrWinFontEntry.mnRefCount > 0);
// keep mrWinFontEntry alive
mrWinFontEntry.mpFontCache->Acquire(&mrWinFontEntry);
}
@@ -4288,6 +4289,11 @@ int WinSalGraphics::GetMinKashidaWidth()
return nMinKashida;
}
+LogicalFontInstance * WinSalGraphics::GetWinFontEntry(int const nFallbackLevel)
+{
+ return mpWinFontEntry[nFallbackLevel];
+}
+
WinFontInstance::WinFontInstance( FontSelectPattern& rFSD )
: LogicalFontInstance( rFSD )
, mpKerningPairs( NULL )