diff --git a/specter/include/Specter/ViewResources.hpp b/specter/include/Specter/ViewResources.hpp index 65c66daad..d64f89f47 100644 --- a/specter/include/Specter/ViewResources.hpp +++ b/specter/include/Specter/ViewResources.hpp @@ -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); diff --git a/specter/lib/ViewResources.cpp b/specter/lib/ViewResources.cpp index c3cc12454..1f9ed1166 100644 --- a/specter/lib/ViewResources.cpp +++ b/specter/lib/ViewResources.cpp @@ -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; }