Kaydet (Commit) df556aa4 authored tarafından Michael Stahl's avatar Michael Stahl

tdf#106933 vcl: delete D2DWriteTextOutRenderer before exit()

As it happens this DirectWrite stuff is using some thread pool
internally, and that must be shutdown before exit(), as Win32 will
terminate all other threads at that point, and then the thread pool
wants to talk to threads that don't exist any more.

https://blogs.msdn.microsoft.com/oldnewthing/20120427-00/?p=7763/

So convert this from a global variable that is deleted from DllMain()
to a member of SalData, so it is deleted from DeInitVCL().

Change-Id: I51408a07c78758cf0c193ab66b9214d0c9dbd9e3
üst 2fd2a7f9
......@@ -39,6 +39,7 @@ class WinSalPrinter;
namespace vcl { class Font; }
struct HDCCache;
struct TempFontItem;
class TextOutRenderer;
#define MAX_STOCKPEN 4
#define MAX_STOCKBRUSH 4
......@@ -118,6 +119,9 @@ public:
std::set< HMENU > mhMenuSet; // keeps track of menu handles created by VCL, used by IsKnownMenuHandle()
std::map< UINT,sal_uInt16 > maVKMap; // map some dynamic VK_* entries
// must be deleted before exit(), so delete it in DeInitSalData()
std::unique_ptr<TextOutRenderer> m_pTextOutRenderer;
};
inline void SetSalData( SalData* pData ) { ImplGetSVData()->mpSalData = pData; }
......
......@@ -39,6 +39,7 @@
#include "win/salobj.h"
#include "win/saltimer.h"
#include "win/salbmp.h"
#include "win/winlayout.hxx"
#include "salimestatus.hxx"
#include "salsys.hxx"
......
......@@ -245,20 +245,26 @@ void D2DWriteTextOutRenderer::CleanupModules()
TextOutRenderer & TextOutRenderer::get(bool bUseDWrite)
{
if (bUseDWrite)
{
static std::unique_ptr<TextOutRenderer> _impl(D2DWriteTextOutRenderer::InitModules()
? static_cast<TextOutRenderer*>(new D2DWriteTextOutRenderer())
: static_cast<TextOutRenderer*>(new ExTextOutRenderer));
SalData *const pSalData = GetSalData();
return *_impl;
if (!pSalData)
{ // don't call this after DeInitVCL()
fprintf(stderr, "TextOutRenderer fatal error: no SalData");
abort();
}
else
{
static std::unique_ptr<TextOutRenderer> _impl(new ExTextOutRenderer);
return *_impl;
if (!pSalData->m_pTextOutRenderer)
{
if (bUseDWrite && D2DWriteTextOutRenderer::InitModules())
{
pSalData->m_pTextOutRenderer.reset(new D2DWriteTextOutRenderer());
}
else
{
pSalData->m_pTextOutRenderer.reset(new ExTextOutRenderer());
}
}
return *pSalData->m_pTextOutRenderer;
}
......
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