Kaydet (Commit) ba24290d authored tarafından Michael Stahl's avatar Michael Stahl Kaydeden (comit) Andras Timar

vcl: fix resource management issue in WinSalLayout

Since commit 65a66d41 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 34700400)
Reviewed-on: https://gerrit.libreoffice.org/18121Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst cd491e8c
...@@ -36,6 +36,7 @@ class PhysicalFontFamily; ...@@ -36,6 +36,7 @@ class PhysicalFontFamily;
class ImplGetDevFontList; class ImplGetDevFontList;
class ImplGetDevSizeList; class ImplGetDevSizeList;
class ImplFontEntry; class ImplFontEntry;
class ImplFontCache;
class ImplPreMatchFontSubstitution; class ImplPreMatchFontSubstitution;
class ImplGlyphFallbackFontSubstitution; class ImplGlyphFallbackFontSubstitution;
class FontSelectPattern; class FontSelectPattern;
...@@ -227,6 +228,7 @@ public: ...@@ -227,6 +228,7 @@ public:
virtual ~ImplFontEntry(); virtual ~ImplFontEntry();
public: // TODO: make data members private public: // TODO: make data members private
ImplFontCache * m_pFontCache;
FontSelectPattern maFontSelData; // FontSelectionData FontSelectPattern maFontSelData; // FontSelectionData
ImplFontMetricData maMetric; // Font Metric ImplFontMetricData maMetric; // Font Metric
const ConvertChar* mpConversion; // used e.g. for StarBats->StarSymbol const ConvertChar* mpConversion; // used e.g. for StarBats->StarSymbol
......
...@@ -970,7 +970,8 @@ vcl::Font OutputDevice::GetDefaultFont( DefaultFontType nType, LanguageType eLan ...@@ -970,7 +970,8 @@ vcl::Font OutputDevice::GetDefaultFont( DefaultFontType nType, LanguageType eLan
} }
ImplFontEntry::ImplFontEntry( const FontSelectPattern& rFontSelData ) ImplFontEntry::ImplFontEntry( const FontSelectPattern& rFontSelData )
: maFontSelData( rFontSelData ) : m_pFontCache(nullptr)
, maFontSelData( rFontSelData )
, maMetric( rFontSelData ) , maMetric( rFontSelData )
, mpConversion( NULL ) , mpConversion( NULL )
, mnLineHeight( 0 ) , mnLineHeight( 0 )
...@@ -987,6 +988,7 @@ ImplFontEntry::ImplFontEntry( const FontSelectPattern& rFontSelData ) ...@@ -987,6 +988,7 @@ ImplFontEntry::ImplFontEntry( const FontSelectPattern& rFontSelData )
ImplFontEntry::~ImplFontEntry() ImplFontEntry::~ImplFontEntry()
{ {
delete mpUnicodeFallbackList; delete mpUnicodeFallbackList;
m_pFontCache = nullptr;
} }
size_t ImplFontEntry::GFBCacheKey_Hash::operator()( const GFBCacheKey& rData ) const size_t ImplFontEntry::GFBCacheKey_Hash::operator()( const GFBCacheKey& rData ) const
...@@ -1322,6 +1324,7 @@ ImplFontEntry* ImplFontCache::GetFontEntry( PhysicalFontCollection* pFontList, ...@@ -1322,6 +1324,7 @@ ImplFontEntry* ImplFontCache::GetFontEntry( PhysicalFontCollection* pFontList,
{ {
// create a new logical font instance from this physical font face // create a new logical font instance from this physical font face
pEntry = pFontData->CreateFontInstance( aFontSelData ); pEntry = pFontData->CreateFontInstance( aFontSelData );
pEntry->m_pFontCache = this;
// if we're subtituting from or to a symbol font we may need a symbol // if we're subtituting from or to a symbol font we may need a symbol
// conversion table // conversion table
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <vcl/opengl/OpenGLHelper.hxx> #include <vcl/opengl/OpenGLHelper.hxx>
#include <win/salgdi.h> #include <win/salgdi.h>
#include <win/saldata.hxx> #include <win/saldata.hxx>
#include <outdev.h>
#include "sft.hxx" #include "sft.hxx"
#include "sallayout.hxx" #include "sallayout.hxx"
...@@ -453,7 +454,14 @@ WinLayout::WinLayout(HDC hDC, const ImplWinFontData& rWFD, ImplWinFontEntry& rWF ...@@ -453,7 +454,14 @@ WinLayout::WinLayout(HDC hDC, const ImplWinFontData& rWFD, ImplWinFontEntry& rWF
mrWinFontData( rWFD ), mrWinFontData( rWFD ),
mrWinFontEntry(rWFE), mrWinFontEntry(rWFE),
mbUseOpenGL(bUseOpenGL) mbUseOpenGL(bUseOpenGL)
{} {
++mrWinFontEntry.mnRefCount; // keep it alive
}
WinLayout::~WinLayout()
{
mrWinFontEntry.m_pFontCache->Release(&mrWinFontEntry);
}
void WinLayout::InitFont() const void WinLayout::InitFont() const
{ {
......
...@@ -41,6 +41,7 @@ class WinLayout : public SalLayout ...@@ -41,6 +41,7 @@ class WinLayout : public SalLayout
{ {
public: public:
WinLayout(HDC, const ImplWinFontData&, ImplWinFontEntry&, bool bUseOpenGL); WinLayout(HDC, const ImplWinFontData&, ImplWinFontEntry&, bool bUseOpenGL);
virtual ~WinLayout();
virtual void InitFont() const SAL_OVERRIDE; virtual void InitFont() const SAL_OVERRIDE;
void SetFontScale( float f ) { mfFontScale = f; } void SetFontScale( float f ) { mfFontScale = f; }
HFONT DisableFontScaling() const; HFONT DisableFontScaling() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment