Commit e5ab9d3b authored by Yuliana's avatar Yuliana Committed by Adam Reichold

Make initialization of globalParams in the cpp frontend threadsafe so that...

Make initialization of globalParams in the cpp frontend threadsafe so that multiple threads can create documents concurrently.
parent ef3ef702
......@@ -44,6 +44,7 @@ public:
initer& operator=(const initer &) = delete;
private:
static std::mutex mutex;
static unsigned int count;
};
......
......@@ -42,10 +42,13 @@
using namespace poppler;
std::mutex poppler::initer::mutex;
unsigned int poppler::initer::count = 0U;
initer::initer()
{
std::lock_guard<std::mutex> lock{mutex};
if (!count) {
globalParams = new GlobalParams();
setErrorCallback(detail::error_function, nullptr);
......@@ -55,6 +58,8 @@ initer::initer()
initer::~initer()
{
std::lock_guard<std::mutex> lock{mutex};
if (count > 0) {
--count;
if (!count) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment