[poppler] 2 commits - cpp/poppler-document.cpp cpp/poppler-document-private.h qt5/src

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Dec 6 19:11:24 UTC 2018


 cpp/poppler-document-private.h |    1 +
 cpp/poppler-document.cpp       |    5 +++++
 qt5/src/poppler-document.cc    |    1 +
 qt5/src/poppler-private.cc     |    4 ++++
 qt5/src/poppler-private.h      |    2 ++
 5 files changed, 13 insertions(+)

New commits:
commit 91419d2a2c4966a4e347b78c50b65625164257db
Author: Adam Reichold <adam.reichold at t-online.de>
Date:   Mon Dec 3 19:57:18 2018 +0100

    Make initialization of globalParams in the qt5 frontend threadsafe so that multiple threads can create documents concurrently.

diff --git a/qt5/src/poppler-document.cc b/qt5/src/poppler-document.cc
index ea2fd7e6..6dc7c6fb 100644
--- a/qt5/src/poppler-document.cc
+++ b/qt5/src/poppler-document.cc
@@ -56,6 +56,7 @@
 namespace Poppler {
 
   int DocumentData::count = 0;
+  QMutex DocumentData::mutex;
 
   Document *Document::load(const QString &filePath, const QByteArray &ownerPassword,
 			   const QByteArray &userPassword)
diff --git a/qt5/src/poppler-private.cc b/qt5/src/poppler-private.cc
index 44f2167c..4668f51f 100644
--- a/qt5/src/poppler-private.cc
+++ b/qt5/src/poppler-private.cc
@@ -252,6 +252,8 @@ namespace Debug {
         delete (OptContentModel *)m_optContentModel;
         delete doc;
     
+        QMutexLocker locker{&mutex};
+
         count --;
         if ( count == 0 )
         {
@@ -267,6 +269,8 @@ namespace Debug {
         m_hints = 0;
         m_optContentModel = nullptr;
       
+        QMutexLocker locker{&mutex};
+
         if ( count == 0 )
         {
             utf8Map = nullptr;
diff --git a/qt5/src/poppler-private.h b/qt5/src/poppler-private.h
index 8b2513cf..12a360c6 100644
--- a/qt5/src/poppler-private.h
+++ b/qt5/src/poppler-private.h
@@ -35,6 +35,7 @@
 #define _POPPLER_PRIVATE_H_
 
 #include <QtCore/QFile>
+#include <QtCore/QMutex>
 #include <QtCore/QPointer>
 #include <QtCore/QVector>
 
@@ -152,6 +153,7 @@ namespace Poppler {
 	QColor paperColor;
 	int m_hints;
 	static int count;
+	static QMutex mutex;
     };
 
     class FontInfoData
commit e5ab9d3b387117d3d6f2e52de5d35882057fa209
Author: Yuliana <vinograduss at mail.ru>
Date:   Mon Dec 3 19:50:50 2018 +0100

    Make initialization of globalParams in the cpp frontend threadsafe so that multiple threads can create documents concurrently.

diff --git a/cpp/poppler-document-private.h b/cpp/poppler-document-private.h
index 2121f1e1..901c22ce 100644
--- a/cpp/poppler-document-private.h
+++ b/cpp/poppler-document-private.h
@@ -44,6 +44,7 @@ public:
     initer& operator=(const initer &) = delete;
 
 private:
+    static std::mutex mutex;
     static unsigned int count;
 };
 
diff --git a/cpp/poppler-document.cpp b/cpp/poppler-document.cpp
index b1d9451f..77fd24d6 100644
--- a/cpp/poppler-document.cpp
+++ b/cpp/poppler-document.cpp
@@ -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) {


More information about the poppler mailing list