summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-08-28 18:37:37 +0200
committerCaolán McNamara <caolanm@redhat.com>2015-08-29 20:13:58 +0000
commit11b8ef34669e01f5bd9847537f4248be48066d9b (patch)
tree690288467eebeec3d46f9144009bac55260b7e29
parentcbcd7f88c2f800ac5fc95670eba26730d389c92f (diff)
vcl: fix resource management issue in WinSalLayout
Since commit 65a66d41fd0e13d0aad9df935091b731b4af650a the sd_exports_test crashes on Windows in UniscribeLayout because it uses a ImplFontEntry that has been removed from the font cache. Tweak the refcount in WinLayout so it will be valid. Change-Id: Ic4bf984ea9fd70de9fa95ca964ae12d95d47d5bf (cherry picked from commit 34700400247e378e074ce4164ab2809edb092201) Reviewed-on: https://gerrit.libreoffice.org/18121 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/inc/outfont.hxx2
-rw-r--r--vcl/source/outdev/font.cxx5
-rw-r--r--vcl/win/source/gdi/winlayout.cxx10
-rw-r--r--vcl/win/source/gdi/winlayout.hxx1
4 files changed, 16 insertions, 2 deletions
diff --git a/vcl/inc/outfont.hxx b/vcl/inc/outfont.hxx
index 6e03bf80a2a2..78e1a8f65c63 100644
--- a/vcl/inc/outfont.hxx
+++ b/vcl/inc/outfont.hxx
@@ -36,6 +36,7 @@ class PhysicalFontFamily;
class ImplGetDevFontList;
class ImplGetDevSizeList;
class ImplFontEntry;
+class ImplFontCache;
class ImplPreMatchFontSubstitution;
class ImplGlyphFallbackFontSubstitution;
class FontSelectPattern;
@@ -227,6 +228,7 @@ public:
virtual ~ImplFontEntry();
public: // TODO: make data members private
+ ImplFontCache * m_pFontCache;
FontSelectPattern maFontSelData; // FontSelectionData
ImplFontMetricData maMetric; // Font Metric
const ConvertChar* mpConversion; // used e.g. for StarBats->StarSymbol
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index 216c8a6f8fcd..355e8afbe2e2 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -970,7 +970,8 @@ vcl::Font OutputDevice::GetDefaultFont( DefaultFontType nType, LanguageType eLan
}
ImplFontEntry::ImplFontEntry( const FontSelectPattern& rFontSelData )
- : maFontSelData( rFontSelData )
+ : m_pFontCache(nullptr)
+ , maFontSelData( rFontSelData )
, maMetric( rFontSelData )
, mpConversion( NULL )
, mnLineHeight( 0 )
@@ -987,6 +988,7 @@ ImplFontEntry::ImplFontEntry( const FontSelectPattern& rFontSelData )
ImplFontEntry::~ImplFontEntry()
{
delete mpUnicodeFallbackList;
+ m_pFontCache = nullptr;
}
size_t ImplFontEntry::GFBCacheKey_Hash::operator()( const GFBCacheKey& rData ) const
@@ -1322,6 +1324,7 @@ ImplFontEntry* ImplFontCache::GetFontEntry( PhysicalFontCollection* pFontList,
{
// create a new logical font instance from this physical font face
pEntry = pFontData->CreateFontInstance( aFontSelData );
+ pEntry->m_pFontCache = this;
// if we're subtituting from or to a symbol font we may need a symbol
// conversion table
diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx
index 22b6881c7bca..f0311a454d34 100644
--- a/vcl/win/source/gdi/winlayout.cxx
+++ b/vcl/win/source/gdi/winlayout.cxx
@@ -29,6 +29,7 @@
#include <vcl/opengl/OpenGLHelper.hxx>
#include <win/salgdi.h>
#include <win/saldata.hxx>
+#include <outdev.h>
#include "sft.hxx"
#include "sallayout.hxx"
@@ -453,7 +454,14 @@ WinLayout::WinLayout(HDC hDC, const ImplWinFontData& rWFD, ImplWinFontEntry& rWF
mrWinFontData( rWFD ),
mrWinFontEntry(rWFE),
mbUseOpenGL(bUseOpenGL)
-{}
+{
+ ++mrWinFontEntry.mnRefCount; // keep it alive
+}
+
+WinLayout::~WinLayout()
+{
+ mrWinFontEntry.m_pFontCache->Release(&mrWinFontEntry);
+}
void WinLayout::InitFont() const
{
diff --git a/vcl/win/source/gdi/winlayout.hxx b/vcl/win/source/gdi/winlayout.hxx
index 8855e37478c7..d558d4cc6bc2 100644
--- a/vcl/win/source/gdi/winlayout.hxx
+++ b/vcl/win/source/gdi/winlayout.hxx
@@ -41,6 +41,7 @@ class WinLayout : public SalLayout
{
public:
WinLayout(HDC, const ImplWinFontData&, ImplWinFontEntry&, bool bUseOpenGL);
+ virtual ~WinLayout();
virtual void InitFont() const SAL_OVERRIDE;
void SetFontScale( float f ) { mfFontScale = f; }
HFONT DisableFontScaling() const;