Better fontcache crash fix

This commit is contained in:
Jack Andersen 2015-12-12 17:07:12 -10:00
parent d4eaaca453
commit 72bd17890d
2 changed files with 12 additions and 1 deletions

View File

@ -77,6 +77,7 @@ public:
Specter::FontTag m_curveFont;
std::thread m_fcacheThread;
bool m_fcacheInterrupt = false;
bool m_fcacheReady = false;
ViewResources() = default;
@ -87,7 +88,11 @@ public:
~ViewResources()
{
m_fcacheThread.detach();
if (m_fcacheThread.joinable())
{
m_fcacheInterrupt = true;
m_fcacheThread.join();
}
}
void init(boo::IGraphicsDataFactory* factory, FontCache* fcache, const ThemeData& theme, float pixelFactor);

View File

@ -37,11 +37,17 @@ void ViewResources::init(boo::IGraphicsDataFactory* factory, FontCache* fcache,
void ViewResources::prepFontCacheSync()
{
unsigned dpi = 72.f * m_pixelFactor;
if (m_fcacheInterrupt) return;
m_mainFont = m_fcache->prepMainFont(m_factory, AllCharFilter, false, 10.f, dpi);
if (m_fcacheInterrupt) return;
m_monoFont = m_fcache->prepMonoFont(m_factory, AllCharFilter, false, 10.f, dpi);
if (m_fcacheInterrupt) return;
m_heading14 = m_fcache->prepMainFont(m_factory, LatinAndJapaneseCharFilter, false, 14.f, dpi);
if (m_fcacheInterrupt) return;
m_heading18 = m_fcache->prepMainFont(m_factory, LatinAndJapaneseCharFilter, false, 18.f, dpi);
if (m_fcacheInterrupt) return;
m_titleFont = m_fcache->prepMainFont(m_factory, LatinCharFilter, false, 36.f, dpi);
if (m_fcacheInterrupt) return;
m_fcache->closeBuiltinFonts();
m_fcacheReady = true;
}