[poppler] qt4/src

Albert Astals Cid aacid at kemper.freedesktop.org
Tue Feb 8 11:57:22 PST 2011


 qt4/src/poppler-private.cc |   51 ++++++++++++++++++++++++++++++++++++++-------
 qt4/src/poppler-private.h  |   34 ++----------------------------
 2 files changed, 47 insertions(+), 38 deletions(-)

New commits:
commit 96e169b0eca31891f3cd564365d4a2a5c6e2a2c0
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue Feb 8 19:58:31 2011 +0000

    Make really sure the uMap static pointer is valid
    
    It might happen you are extremely unlucky and get the same globalParams after a new delete/creation

diff --git a/qt4/src/poppler-private.cc b/qt4/src/poppler-private.cc
index 253222e..d6e3265 100644
--- a/qt4/src/poppler-private.cc
+++ b/qt4/src/poppler-private.cc
@@ -45,6 +45,8 @@ namespace Debug {
 
 }
 
+    static UnicodeMap *utf8Map = 0;
+
     void setDebugErrorFunction(PopplerDebugFunc function, const QVariant &closure)
     {
         Debug::debugFunction = function ? function : Debug::qDebugDebugFunction;
@@ -70,14 +72,11 @@ namespace Debug {
     }
 
     QString unicodeToQString(Unicode* u, int len) {
-        static UnicodeMap *uMap = 0;
-        static GlobalParams *gParams = globalParams;
-        if (!uMap || gParams != globalParams)
+        if (!utf8Map)
         {
                 GooString enc("UTF-8");
-                uMap = globalParams->getUnicodeMap(&enc);
-                uMap->incRefCnt();
-                gParams = globalParams;
+                utf8Map = globalParams->getUnicodeMap(&enc);
+                utf8Map->incRefCnt();
         }
 
         // ignore the last character if it is 0x0
@@ -90,7 +89,7 @@ namespace Debug {
         for (int i = 0; i < len; ++i)
         {
             char buf[8];
-            const int n = uMap->mapUnicode(u[i], buf, sizeof(buf));
+            const int n = utf8Map->mapUnicode(u[i], buf, sizeof(buf));
             convertedStr.append(buf, n);
         }
 
@@ -223,6 +222,44 @@ namespace Debug {
             default: ;
         }
     }
+    
+    DocumentData::~DocumentData()
+    {
+        qDeleteAll(m_embeddedFiles);
+        delete (OptContentModel *)m_optContentModel;
+        delete doc;
+        delete m_outputDev;
+        delete m_fontInfoIterator;
+    
+        count --;
+        if ( count == 0 )
+        {
+            utf8Map = 0;
+            delete globalParams;
+        }
+      }
+    
+    void DocumentData::init(GooString *ownerPassword, GooString *userPassword)
+    {
+        m_fontInfoIterator = 0;
+        m_backend = Document::SplashBackend;
+        m_outputDev = 0;
+        paperColor = Qt::white;
+        m_hints = 0;
+        m_optContentModel = 0;
+        // It might be more appropriate to delete these in PDFDoc
+        delete ownerPassword;
+        delete userPassword;
+      
+        if ( count == 0 )
+        {
+            utf8Map = 0;
+            globalParams = new GlobalParams();
+            setErrorFunction(qt4ErrorFunction);
+        }
+        count ++;
+    }
+
 
     void DocumentData::addTocChildren( QDomDocument * docSyn, QDomNode * parent, GooList * items )
     {
diff --git a/qt4/src/poppler-private.h b/qt4/src/poppler-private.h
index e3493fa..6800a8b 100644
--- a/qt4/src/poppler-private.h
+++ b/qt4/src/poppler-private.h
@@ -1,7 +1,7 @@
 /* poppler-private.h: qt interface to poppler
  * Copyright (C) 2005, Net Integration Technologies, Inc.
  * Copyright (C) 2005, 2008, Brad Hards <bradh at frogmouth.net>
- * Copyright (C) 2006-2009 by Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2006-2009, 2011 by Albert Astals Cid <aacid at kde.org>
  * Copyright (C) 2007-2009 by Pino Toscano <pino at kde.org>
  * Copyright (C) 2011 Andreas Hartmetz <ahartmetz at gmail.com>
  * Inspired on code by
@@ -90,37 +90,9 @@ namespace Poppler {
 		init(ownerPassword, userPassword);
 	    }
 	
-	void init(GooString *ownerPassword, GooString *userPassword)
-	    {
-		m_fontInfoIterator = 0;
-		m_backend = Document::SplashBackend;
-		m_outputDev = 0;
-		paperColor = Qt::white;
-		m_hints = 0;
-		m_optContentModel = 0;
-		// It might be more appropriate to delete these in PDFDoc
-		delete ownerPassword;
-		delete userPassword;
-		
-		if ( count == 0 )
-		{
-			globalParams = new GlobalParams();
-			setErrorFunction(qt4ErrorFunction);
-		}
-		count ++;
-	    }
+	void init(GooString *ownerPassword, GooString *userPassword);
 	
-	~DocumentData()
-	{
-		qDeleteAll(m_embeddedFiles);
-		delete (OptContentModel *)m_optContentModel;
-		delete doc;
-		delete m_outputDev;
-		delete m_fontInfoIterator;
-		
-		count --;
-		if ( count == 0 ) delete globalParams;
-	}
+	~DocumentData();
 	
 	OutputDev *getOutputDev()
 	{


More information about the poppler mailing list