summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal <sudolskym@gmail.com>2020-01-04 21:49:29 +0000
committerAlbert Astals Cid <tsdgeos@yahoo.es>2020-01-04 23:35:40 +0000
commit9e15cbae552be5a7b787a07e661ab849427537aa (patch)
tree3aa4f76e2eee3871c3fb026398abce9e0ef39619
parent9349ed71f9fabc8961cc1dd9ca57aca8be7939db (diff)
make FT_Library initialisation thread-safe
-rw-r--r--poppler/CairoOutputDev.cc7
-rw-r--r--poppler/CairoOutputDev.h2
2 files changed, 3 insertions, 6 deletions
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;