Initial patch attached.
Limited testing so far:
- No win32 test build, known issues in win32 code
- No test w threading disabled, known issues w/o threading
- Only basic pthread testing
Cmake isn't yet conditionally compiling the .cpp parts yet either, but
that'll only take me a sec.
Expect a commit with the finished and tested changes later tonight
(+0800 time).
--
Craig Ringer
Index: src/PdfFontCache.h
===================================================================
--- src/PdfFontCache.h (revision 1136)
+++ src/PdfFontCache.h (working copy)
@@ -27,6 +27,14 @@
#include "PdfEncodingFactory.h"
#include "PdfFont.h"
+#ifdef BUILDING_PODOFO
+#if defined(PODOFO_HAVE_FONTCONFIG)
+#include "util/PdfMutex.h"
+#endif
+#else // BUILDING_PODOFO
+namespace PoDoFo { namespace Util { class PdfReentrantMutex; }; };
+#endif // BUILDING_PODOFO
+
namespace PoDoFo {
class PdfFontMetrics;
@@ -128,7 +136,11 @@
typedef TSortedFontList::iterator TISortedFontList;
typedef TSortedFontList::const_iterator TCISortedFontList;
+#if defined(PODOFO_HAVE_FONTCONFIG)
+ static Util::PdfReentrantMutex m_FcMutex;
+#endif
+
public:
/** Create an empty font cache
*
Index: src/util/PdfMutexImpl_noop.h
===================================================================
--- src/util/PdfMutexImpl_noop.h (revision 0)
+++ src/util/PdfMutexImpl_noop.h (revision 0)
@@ -0,0 +1,67 @@
+/***************************************************************************
+ * Copyright (C) 2008 by Dominik Seichter, Craig Ringer *
+ * [email protected] *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public *
+ * License along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "../PdfDefines.h"
+#include "../PdfDefinesPrivate.h"
+
+#if defined(PODOFO_MULTI_THREAD)
+#error "Multi-thread build, a real PdfMutex implementation should be used instead"
+#endif
+
+namespace PoDoFo {
+namespace Util {
+
+/**
+ * A platform independent non-reentrant mutex, no-op implementation.
+ * This version is used if PoDoFo is built without threading support.
+ *
+ * PdfMutex is *NOT* part of PoDoFo's public API.
+ */
+template<bool Recursive>
+class PdfMutexImpl {
+ public:
+ /** Construct a new mutex
+ */
+ inline PdfMutexImpl() { }
+
+ inline ~PdfMutexImpl() { }
+
+ /**
+ * Lock the mutex
+ */
+ inline void Lock() { }
+
+ /**
+ * Try locking the mutex.
+ *
+ * \returns true if the mutex was locked
+ * \returns false if the mutex is already locked
+ * by some other thread
+ */
+ inline bool TryLock() { return true; }
+
+ /**
+ * Unlock the mutex
+ */
+ inline void UnLock() { }
+};
+
+}; // Util
+}; // PoDoFo
Index: src/util/PdfMutex.h
===================================================================
--- src/util/PdfMutex.h (revision 1136)
+++ src/util/PdfMutex.h (working copy)
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008 by Dominik Seichter *
+ * Copyright (C) 2008 by Dominik Seichter, Craig Ringer *
* [email protected] *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -18,70 +18,45 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
-#ifndef _PDF_MUTEX_H_
-#define _PDF_MUTEX_H_
+#ifndef PDF_PDFMUTEX_H
+#define PDF_PDFMUTEX_H
-#include "../PdfDefines.h"
-// PdfMutex.h is a private implementation header. It includes PdfDefinesPrivate.h
-// to gain access to win32 APIs.
-#include "../PdfDefinesPrivate.h"
+#if !defined(BUILDING_PODOFO)
+#error "PdfMutex.h is a private header and isn't part of PoDoFo's public API"
+#endif
-namespace PoDoFo {
-namespace Util {
+/* Import the platform-specific implementation of PdfMutex */
+#if defined(PODOFO_MULTI_THREAD)
+# if defined(_WIN32)
+# include "PdfMutexImpl_win32.h"
+# else
+# include "PdfMutexImpl_pthread.h"
+# endif
+#else
+# include "PdfMutexImpl_noop.h"
+#endif
-/** A plattform independent mutex.
- *
- * Uses pthreads on Unix and critical sections
- * on Windows.
- *
- * If PODOFO_MULTI_THREAD is not defined during
- * the build, this class does nothing.
- *
- * PdfMutex is *NOT* part of PoDoFo's public API.
+namespace PoDoFo { namespace Util {
+
+/**
+ * Non-reentrant mutex
*/
-class PdfMutex {
+class PdfMutex : public PdfMutexImpl<false> {
public:
- /** Construct a new mutex
- */
- PdfMutex();
+ PdfMutex() { }
+ ~PdfMutex() { }
+};
- ~PdfMutex();
-
- /**
- * Query if this is a multithreaded PoDoFo build.
- */
- static bool IsPoDoFoMultiThread();
-
- /**
- * Lock the mutex
- */
- void Lock();
-
- /**
- * Try locking the mutex.
- *
- * \returns true if the mutex was locked
- * \returns false if the mutex is already locked
- * by some other thread
- */
- bool TryLock();
-
- /**
- * Unlock the mutex
- */
- void UnLock();
-
- private:
-#ifdef PODOFO_MULTI_THREAD
-#ifdef _WIN32
- CRITICAL_SECTION m_cs;
-#else
- pthread_mutex_t m_mutex;
-#endif // _WIN32
-#endif // PODOFO_MULTI_THREAD
+/**
+ * Reentrant mutex
+ */
+class PdfReentrantMutex : public PdfMutexImpl<true> {
+ public:
+ PdfReentrantMutex() { }
+ ~PdfReentrantMutex() { }
};
-}; // Util
-}; // PoDoFo
+};};
-#endif // _PDF_MUTEX_H_
+
+#endif
Index: src/util/PdfMutexWrapper.h
===================================================================
--- src/util/PdfMutexWrapper.h (revision 1136)
+++ src/util/PdfMutexWrapper.h (working copy)
@@ -28,31 +28,54 @@
namespace Util {
/**
- * A wrapper around PdfMutex.
+ * A wrapper around a mutex supporting the PdfMutex interface.
* The mutex is locked in the constructor
* and unlocked in the destructor.
*
* All exceptions that might be thrown by PdfMutex
* are catched and logged.
*
- * PdfMutexWrapper is *not* part of PoDoFo's public API.
+ * PdfMutexWrapperBase is *not* part of PoDoFo's public API.
*/
-class PdfMutexWrapper {
+template<typename MutexType>
+class PdfMutexWrapperBase {
+ MutexType& m_rMutex;
public:
/** Lock a mutex.
*
* \param rMutex the mutex to be locked.
*/
- PODOFO_NOTHROW PdfMutexWrapper( PdfMutex & rMutex );
+ PODOFO_NOTHROW inline PdfMutexWrapperBase( MutexType & rMutex );
/** Unlocks the mutex on destruction
*/
- ~PdfMutexWrapper();
-
- private:
- PdfMutex& m_rMutex;
+ inline ~PdfMutexWrapperBase();
};
+typedef PdfMutexWrapperBase<PdfMutex> PdfMutexWrapper;
+typedef PdfMutexWrapperBase<PdfReentrantMutex> PdfReentrantMutexWrapper;
+
+template<typename MutexType>
+PdfMutexWrapperBase<MutexType>::PdfMutexWrapperBase( MutexType & rMutex )
+ : m_rMutex( rMutex )
+{
+ m_rMutex.Lock();
+}
+
+template<typename MutexType>
+PdfMutexWrapperBase<MutexType>::~PdfMutexWrapperBase()
+{
+ // FIXME: call sites should handle this, not the mutex wrapper. It's hiding
+ // threading exceptions from callers.
+ try {
+ m_rMutex.UnLock();
+ }
+ catch( const PdfError & rError )
+ {
+ rError.PrintErrorMsg();
+ }
+}
+
}; // Util
}; // PoDoFo
Index: src/util/PdfMutexImpl_win32.h
===================================================================
--- src/util/PdfMutexImpl_win32.h (revision 0)
+++ src/util/PdfMutexImpl_win32.h (revision 0)
@@ -0,0 +1,97 @@
+/***************************************************************************
+ * Copyright (C) 2008 by Dominik Seichter *
+ * [email protected] *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public *
+ * License along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "../PdfDefines.h"
+#include "../PdfDefinesPrivate.h"
+
+#if ! defined(PODOFO_MULTI_THREAD)
+#error "Not a multi-thread build. PdfMutex_null.h should be used instead"
+#endif
+
+#if !defined(_WIN32)
+#error "Wrong PdfMutex implementation included!"
+#endif
+
+namespace PoDoFo {
+namespace Util {
+
+/**
+ * A platform independent non-reentrant mutex, win32 implementation.
+ */
+template <bool Recursive>
+class PdfMutexImpl {
+ public:
+ /** Construct a new mutex
+ */
+ inline PdfMutexImpl();
+
+ inline ~PdfMutexImpl();
+
+ /**
+ * Lock the mutex
+ */
+ inline void Lock();
+
+ /**
+ * Try locking the mutex.
+ *
+ * \returns true if the mutex was locked
+ * \returns false if the mutex is already locked
+ * by some other thread
+ */
+ inline bool TryLock();
+
+ /**
+ * Unlock the mutex
+ */
+ inline void UnLock();
+
+ private:
+ CRITICAL_SECTION m_cs;
+};
+
+PdfMutexImpl::PdfMutexImpl()
+{
+ InitializeCriticalSection( &m_cs );
+}
+
+PdfMutexImpl::~PdfMutexImpl()
+{
+ DeleteCriticalSection( &m_cs );
+}
+
+void PdfMutexImpl::Lock()
+{
+ EnterCriticalSection( &m_cs );
+}
+
+bool PdfMutexImpl::TryLock()
+{
+ return (TryEnterCriticalSection( &m_cs ) ? true : false);
+}
+
+void PdfMutexImpl::UnLock()
+{
+ LeaveCriticalSection( &m_cs );
+}
+
+
+}; // Util
+}; // PoDoFo
Property changes on: src/util/PdfMutexImpl_win32.h
___________________________________________________________________
Added: svn:mergeinfo
Index: src/util/PdfMutexImpl_pthread.cpp
===================================================================
--- src/util/PdfMutexImpl_pthread.cpp (revision 0)
+++ src/util/PdfMutexImpl_pthread.cpp (revision 0)
@@ -0,0 +1,46 @@
+/***************************************************************************
+ * Copyright (C) 2008 by Dominik Seichter, Craig Ringer *
+ * [email protected] *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public *
+ * License along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "PdfMutexImpl_pthread.h"
+
+namespace PoDoFo {
+namespace Util {
+
+template<>
+PdfMutexImpl<true>::PdfMutexImpl() {
+ pthread_mutexattr_t attr;
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+ Init(&attr);
+}
+
+template<>
+PdfMutexImpl<false>::PdfMutexImpl() {
+ pthread_mutexattr_t attr;
+ pthread_mutexattr_settype(&attr, PODOFO_DFL_MUTEX_TYPE);
+ Init(&attr);
+}
+
+template<>
+PdfMutexImpl<false>::~PdfMutexImpl() { }
+
+template<>
+PdfMutexImpl<true>::~PdfMutexImpl() { }
+
+}; };
Index: src/util/PdfMutexImpl_pthread.h
===================================================================
--- src/util/PdfMutexImpl_pthread.h (revision 0)
+++ src/util/PdfMutexImpl_pthread.h (revision 0)
@@ -0,0 +1,128 @@
+/***************************************************************************
+ * Copyright (C) 2008 by Dominik Seichter, Craig Ringer *
+ * [email protected] *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License as *
+ * published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public *
+ * License along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "../PdfDefines.h"
+#include "../PdfDefinesPrivate.h"
+
+#if ! defined(PODOFO_MULTI_THREAD)
+#error "Not a multi-thread build. PdfMutex_null.h should be used instead"
+#endif
+
+#if defined(_WIN32)
+#error "win32 build. PdfMutex_win32.h should be used instead"
+#endif
+
+#include <pthread.h>
+#include <errno.h>
+
+namespace PoDoFo {
+namespace Util {
+
+/**
+ * A platform independent non-reentrant mutex, pthread implementation.
+ *
+ * PdfMutex is *NOT* part of PoDoFo's public API.
+ *
+ * This is the pthread implementation, which is
+ * entirely inline.
+ */
+class PdfMutexImplBase {
+ pthread_mutex_t m_mutex;
+ public:
+
+ PdfMutexImplBase() {}
+
+ inline ~PdfMutexImplBase();
+
+ inline void Init( const pthread_mutexattr_t *attr );
+
+ /**
+ * Lock the mutex
+ */
+ inline void Lock();
+
+ /**
+ * Try locking the mutex.
+ *
+ * \returns true if the mutex was locked
+ * \returns false if the mutex is already locked
+ * by some other thread
+ */
+ inline bool TryLock();
+
+ /**
+ * Unlock the mutex
+ */
+ inline void UnLock();
+};
+
+#if defined(DEBUG)
+# define PODOFO_DFL_MUTEX_TYPE PTHREAD_MUTEX_ERRORCHECK
+#else
+# define PODOFO_DFL_MUTEX_TYPE PTHREAD_MUTEX_NORMAL
+#endif
+
+template<bool Recursive>
+class PdfMutexImpl : public PdfMutexImplBase {
+ public:
+ PdfMutexImpl();
+ ~PdfMutexImpl();
+};
+
+void PdfMutexImplBase::Init(const pthread_mutexattr_t *attr) {
+ pthread_mutex_init( &m_mutex, attr );
+}
+
+PdfMutexImplBase::~PdfMutexImplBase()
+{
+ pthread_mutex_destroy( &m_mutex );
+}
+
+void PdfMutexImplBase::Lock()
+{
+ if( pthread_mutex_lock( &m_mutex ) != 0 )
+ {
+ PODOFO_RAISE_ERROR( ePdfError_MutexError );
+ }
+}
+
+bool PdfMutexImplBase::TryLock()
+{
+ int nRet = pthread_mutex_trylock( &m_mutex );
+ if( nRet == 0 )
+ return true;
+ else if( nRet == EBUSY )
+ return false;
+ else
+ {
+ PODOFO_RAISE_ERROR( ePdfError_MutexError );
+ }
+}
+
+void PdfMutexImplBase::UnLock()
+{
+ if( pthread_mutex_unlock( &m_mutex ) != 0 )
+ {
+ PODOFO_RAISE_ERROR( ePdfError_MutexError );
+ }
+}
+
+}; // Util
+}; // PoDoFo
Property changes on: src/util/PdfMutexImpl_pthread.h
___________________________________________________________________
Added: svn:mergeinfo
Index: src/util/PdfMutex.cpp
===================================================================
--- src/util/PdfMutex.cpp (revision 1136)
+++ src/util/PdfMutex.cpp (working copy)
@@ -1,112 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2008 by Dominik Seichter *
- * [email protected] *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU Library General Public License as *
- * published by the Free Software Foundation; either version 2 of the *
- * License, or (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU Library General Public *
- * License along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-
-#include "PdfMutex.h"
-
-#include <errno.h>
-
-namespace PoDoFo {
-namespace Util {
-
-bool PdfMutex::IsPoDoFoMultiThread()
-{
-#ifdef PODOFO_MULTI_THREAD
- return true;
-#else
- return false;
-#endif // PODOFO_MULTI_THREAD
-}
-
-PdfMutex::PdfMutex()
-{
-#ifdef PODOFO_MULTI_THREAD
-#ifdef _WIN32
- InitializeCriticalSection( &m_cs );
-#else
- pthread_mutex_init( &m_mutex, NULL );
-#endif // _WIN32
-#endif // PODOFO_MULTI_THREAD
-}
-
-PdfMutex::~PdfMutex()
-{
-#ifdef PODOFO_MULTI_THREAD
-#ifdef _WIN32
- DeleteCriticalSection( &m_cs );
-#else
- pthread_mutex_destroy( &m_mutex );
-#endif // _WIN32
-#endif // PODOFO_MULTI_THREAD
-}
-
-void PdfMutex::Lock()
-{
-#ifdef PODOFO_MULTI_THREAD
-#ifdef _WIN32
- EnterCriticalSection( &m_cs );
-#else
- if( pthread_mutex_lock( &m_mutex ) != 0 )
- {
- PODOFO_RAISE_ERROR( ePdfError_MutexError );
- }
-#endif // _WIN32
-#endif // PODOFO_MULTI_THREAD
-}
-
-bool PdfMutex::TryLock()
-{
-#ifdef PODOFO_MULTI_THREAD
-#ifdef _WIN32
- return (TryEnterCriticalSection( &m_cs ) ? true : false);
-#else
- int nRet = pthread_mutex_trylock( &m_mutex );
- if( nRet == 0 )
- return true;
- else if( nRet == EBUSY )
- return false;
- else
- {
- PODOFO_RAISE_ERROR( ePdfError_MutexError );
- }
-#endif // _WIN32
-#endif // PODOFO_MULTI_THREAD
-
- // If we have no multithreading support always
- // simulate succesfull locking
- return true;
-}
-
-void PdfMutex::UnLock()
-{
-#ifdef PODOFO_MULTI_THREAD
-#ifdef _WIN32
- LeaveCriticalSection( &m_cs );
-#else
- if( pthread_mutex_unlock( &m_mutex ) != 0 )
- {
- PODOFO_RAISE_ERROR( ePdfError_MutexError );
- }
-#endif // _WIN32
-#endif // PODOFO_MULTI_THREAD
-}
-
-
-}; // Util
-}; // PoDoFo
Index: src/util/PdfMutexWrapper.cpp
===================================================================
--- src/util/PdfMutexWrapper.cpp (revision 1136)
+++ src/util/PdfMutexWrapper.cpp (working copy)
@@ -1,47 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2008 by Dominik Seichter *
- * [email protected] *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU Library General Public License as *
- * published by the Free Software Foundation; either version 2 of the *
- * License, or (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU Library General Public *
- * License along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-
-#include "PdfMutexWrapper.h"
-
-
-namespace PoDoFo {
-namespace Util {
-
-PdfMutexWrapper::PdfMutexWrapper( PdfMutex & rMutex )
- : m_rMutex( rMutex )
-{
- m_rMutex.Lock();
-}
-
-
-PdfMutexWrapper::~PdfMutexWrapper()
-{
- try {
- m_rMutex.UnLock();
- }
- catch( const PdfError & rError )
- {
- rError.PrintErrorMsg();
- }
-}
-
-
-}; // Util
-}; // PoDoFo
Index: src/CMakeLists.txt
===================================================================
--- src/CMakeLists.txt (revision 1136)
+++ src/CMakeLists.txt (working copy)
@@ -1,3 +1,5 @@
+SET(PlatformMutexImpl util/PdfMutexImpl_pthread.cpp)
+
SET(PODOFO_SOURCES
PdfAction.cpp
PdfAcroForm.cpp
@@ -75,8 +77,7 @@
PdfXObject.cpp
PdfXRef.cpp
PdfXRefStream.cpp
- util/PdfMutex.cpp
- util/PdfMutexWrapper.cpp
+ ${PlatformMutexImpl}
)
IF(WIN32)
@@ -170,6 +171,9 @@
)
SET(PODOFO_HEADERS2
util/PdfMutex.h
+ util/PdfMutex_noop.h
+ util/PdfMutex_win32.h
+ util/PdfMutex_pthread.h
util/PdfMutexWrapper.h
)
Index: src/PdfFontCache.cpp
===================================================================
--- src/PdfFontCache.cpp (revision 1136)
+++ src/PdfFontCache.cpp (working copy)
@@ -54,6 +54,7 @@
#if defined(PODOFO_HAVE_FONTCONFIG)
#include <fontconfig/fontconfig.h>
+#include "util/PdfMutexWrapper.h"
#endif
using namespace std;
@@ -118,13 +119,20 @@
}
#endif // _WIN32
+#if defined(PODOFO_HAVE_FONTCONFIG)
+Util::PdfReentrantMutex PdfFontCache::m_FcMutex;
+#endif
+
PdfFontCache::PdfFontCache( PdfVecObjects* pParent )
: m_pParent( pParent )
{
// Initialize all the fonts stuff
#if defined(PODOFO_HAVE_FONTCONFIG)
+ {
+ Util::PdfReentrantMutexWrapper mutex(m_FcMutex);
m_pFcConfig = static_cast<void*>(FcInitLoadConfigAndFonts());
+ }
#endif
if( FT_Init_FreeType( &m_ftLibrary ) )
@@ -138,7 +146,10 @@
this->EmptyCache();
#if defined(PODOFO_HAVE_FONTCONFIG)
+ {
+ Util::PdfReentrantMutexWrapper mutex(m_FcMutex);
FcConfigDestroy( static_cast<FcConfig*>(m_pFcConfig) );
+ }
#endif
if( m_ftLibrary )
@@ -540,6 +551,7 @@
FcResult result = FcResultMatch;
FcValue v;
std::string sPath;
+ Util::PdfReentrantMutexWrapper mutex(m_FcMutex);
// Build a pattern to search using fontname, bold and italic
pattern = FcPatternBuild (0, FC_FAMILY, FcTypeString, pszFontName,
@@ -575,6 +587,7 @@
std::string PdfFontCache::GetFontPath( const char* pszFontName, bool bBold, bool bItalic )
{
#if defined(PODOFO_HAVE_FONTCONFIG)
+ Util::PdfReentrantMutexWrapper mutex(m_FcMutex);
FcConfig* pConfig = FcInitLoadConfigAndFonts();
std::string sPath = this->GetFontConfigFontPath( pConfig, pszFontName, bBold, bItalic );
FcConfigDestroy( pConfig );
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Podofo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/podofo-users