[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Jan 4 23:42:21 UTC 2020


 poppler/CairoOutputDev.cc |    7 ++-----
 poppler/CairoOutputDev.h  |    2 +-
 2 files changed, 3 insertions(+), 6 deletions(-)

New commits:
commit 9e15cbae552be5a7b787a07e661ab849427537aa
Author: Michal <sudolskym at gmail.com>
Date:   Sat Jan 4 21:49:29 2020 +0000

    make FT_Library initialisation thread-safe

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 52b05cd4..2302f082 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -118,15 +118,12 @@ void CairoImage::setImage (cairo_surface_t *i) {
 // FT_Library instance; to avoid leaks, just use a single global instance
 // initialized the first time it is needed.
 FT_Library CairoOutputDev::ft_lib;
-bool CairoOutputDev::ft_lib_initialized = false;
+std::once_flag CairoOutputDev::ft_lib_once_flag;
 
 CairoOutputDev::CairoOutputDev() {
   doc = nullptr;
 
-  if (!ft_lib_initialized) {
-    FT_Init_FreeType(&ft_lib);
-    ft_lib_initialized = true;
-  }
+  std::call_once(ft_lib_once_flag, FT_Init_FreeType, &ft_lib);
 
   fontEngine = nullptr;
   fontEngine_owner = false;
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index 9da5322b..537560f6 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -320,7 +320,7 @@ protected:
   PDFDoc *doc;			// the current document
 
   static FT_Library ft_lib;
-  static bool ft_lib_initialized;
+  static std::once_flag ft_lib_once_flag;
 
   CairoFontEngine *fontEngine;
   bool fontEngine_owner;


More information about the poppler mailing list