Fix CFX_GEModule destruction order. The platform must outlive the font mgr (which owns the FT library) which must outlive the font cache. This will enable faces to be properly ref-counted in a subsequent patch, since the font cache won't keep faces alive beyond the lifespan of the library. Change-Id: I448dea06cf38cb62c604c9a71ff89404823f9adc Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/54850 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/cfx_gemodule.cpp b/core/fxge/cfx_gemodule.cpp index ea6b4ac..5d268bf 100644 --- a/core/fxge/cfx_gemodule.cpp +++ b/core/fxge/cfx_gemodule.cpp
@@ -18,9 +18,9 @@ } // namespace CFX_GEModule::CFX_GEModule(const char** pUserFontPaths) - : m_pFontCache(pdfium::MakeUnique<CFX_FontCache>()), + : m_pPlatform(PlatformIface::Create()), m_pFontMgr(pdfium::MakeUnique<CFX_FontMgr>()), - m_pPlatform(PlatformIface::Create()), + m_pFontCache(pdfium::MakeUnique<CFX_FontCache>()), m_pUserFontPaths(pUserFontPaths) {} CFX_GEModule::~CFX_GEModule() = default;
diff --git a/core/fxge/cfx_gemodule.h b/core/fxge/cfx_gemodule.h index 59eddb7..47e2667 100644 --- a/core/fxge/cfx_gemodule.h +++ b/core/fxge/cfx_gemodule.h
@@ -35,9 +35,9 @@ explicit CFX_GEModule(const char** pUserFontPaths); ~CFX_GEModule(); - std::unique_ptr<CFX_FontCache> const m_pFontCache; - std::unique_ptr<CFX_FontMgr> const m_pFontMgr; std::unique_ptr<PlatformIface> const m_pPlatform; + std::unique_ptr<CFX_FontMgr> const m_pFontMgr; + std::unique_ptr<CFX_FontCache> const m_pFontCache; const char** const m_pUserFontPaths; };