[poppler] poppler/Annot.cc poppler/Annot.h poppler/FontInfo.cc poppler/FontInfo.h poppler/Page.cc poppler/Page.h poppler/SplashOutputDev.cc poppler/SplashOutputDev.h poppler/XRef.cc qt4/src

Albert Astals Cid aacid at kemper.freedesktop.org
Wed Feb 20 14:16:30 PST 2013


 poppler/Annot.cc                |   97 ++++++++++++++++++++++++++++++++++------
 poppler/Annot.h                 |    8 ++-
 poppler/FontInfo.cc             |   29 ++++++-----
 poppler/FontInfo.h              |    5 +-
 poppler/Page.cc                 |   11 +++-
 poppler/Page.h                  |    6 +-
 poppler/SplashOutputDev.cc      |    7 ++
 poppler/SplashOutputDev.h       |    5 +-
 poppler/XRef.cc                 |    4 +
 qt4/src/poppler-page.cc         |    9 ++-
 qt4/src/poppler-ps-converter.cc |    3 -
 11 files changed, 139 insertions(+), 45 deletions(-)

New commits:
commit 47453a78e52aa43edd148aef53b67306603161f5
Author: Thomas Freitag <Thomas.Freitag at alfa.de>
Date:   Wed Feb 20 23:12:17 2013 +0100

    More threading safety

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 0b3c5e4..48af4eb 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -67,6 +67,14 @@
 #include "Link.h"
 #include <string.h>
 
+#if MULTITHREADED
+#  define lockAnnot   gLockMutex(&mutex)
+#  define unlockAnnot gUnlockMutex(&mutex)
+#else
+#  define lockAnnot
+#  define unlockAnnot
+#endif
+
 #define fieldFlagReadOnly           0x00000001
 #define fieldFlagRequired           0x00000002
 #define fieldFlagNoExport           0x00000004
@@ -1293,6 +1301,10 @@ void Annot::initialize(PDFDoc *docA, Dict *dict) {
   obj1.free();
 
   dict->lookupNF("OC", &oc);
+
+#if MULTITHREADED
+  gInitMutex(&mutex);
+#endif
 }
 
 void Annot::getRect(double *x1, double *y1, double *x2, double *y2) const {
@@ -1338,7 +1350,8 @@ GBool Annot::inRect(double x, double y) const {
   return rect->contains(x, y);
 }
 
-void Annot::update(const char *key, Object *value) {
+void Annot::update(const char *key, Object *value, GBool lock) {
+  if (lock) lockAnnot;
   /* Set M to current time, unless we are updating M itself */
   if (strcmp(key, "M") != 0) {
     delete modified;
@@ -1352,9 +1365,11 @@ void Annot::update(const char *key, Object *value) {
   annotObj.dictSet(const_cast<char*>(key), value);
   
   xref->setModifiedObject(&annotObj, ref);
+  if (lock) unlockAnnot;
 }
 
 void Annot::setContents(GooString *new_content) {
+  lockAnnot;
   delete contents;
 
   if (new_content) {
@@ -1370,10 +1385,12 @@ void Annot::setContents(GooString *new_content) {
   
   Object obj1;
   obj1.initString(contents->copy());
-  update ("Contents", &obj1);
+  update ("Contents", &obj1, gFalse);
+  unlockAnnot;
 }
 
 void Annot::setName(GooString *new_name) {
+  lockAnnot;
   delete name;
 
   if (new_name) {
@@ -1384,10 +1401,12 @@ void Annot::setName(GooString *new_name) {
 
   Object obj1;
   obj1.initString(name->copy());
-  update ("NM", &obj1);
+  update ("NM", &obj1, gFalse);
+  unlockAnnot;
 }
 
 void Annot::setModified(GooString *new_modified) {
+  lockAnnot;
   delete modified;
 
   if (new_modified)
@@ -1397,43 +1416,51 @@ void Annot::setModified(GooString *new_modified) {
 
   Object obj1;
   obj1.initString(modified->copy());
-  update ("M", &obj1);
+  update ("M", &obj1, gFalse);
+  unlockAnnot;
 }
 
 void Annot::setFlags(Guint new_flags) {
+  lockAnnot;
   Object obj1;
   flags = new_flags;
   obj1.initInt(flags);
-  update ("F", &obj1);
+  update ("F", &obj1, gFalse);
+  unlockAnnot;
 }
 
 void Annot::setBorder(AnnotBorderArray *new_border) {
+  lockAnnot;
   delete border;
 
   if (new_border) {
     Object obj1;
     new_border->writeToObject(xref, &obj1);
-    update ("Border", &obj1);
+    update ("Border", &obj1, gFalse);
     border = new_border;
   } else {
     border = NULL;
   }
+  unlockAnnot;
 }
 
 void Annot::setColor(AnnotColor *new_color) {
+  lockAnnot;
   delete color;
 
   if (new_color) {
     Object obj1;
     new_color->writeToObject(xref, &obj1);
-    update ("C", &obj1);
+    update ("C", &obj1, gFalse);
     color = new_color;
   } else {
     color = NULL;
   }
+  unlockAnnot;
 }
 
 void Annot::setPage(int pageIndex, GBool updateP) {
+  lockAnnot;
   Page *pageobj = doc->getPage(pageIndex);
   Object obj1;
 
@@ -1447,14 +1474,16 @@ void Annot::setPage(int pageIndex, GBool updateP) {
   }
 
   if (updateP) {
-    update("P", &obj1);
+    update("P", &obj1, gFalse);
   }
+  unlockAnnot;
 }
 
-void Annot::setAppearanceState(const char *state) {
+void Annot::setAppearanceState(const char *state, GBool lock) {
   if (!state)
     return;
 
+  if (lock) lockAnnot;
   delete appearState;
   appearState = new GooString(state);
 
@@ -1463,7 +1492,7 @@ void Annot::setAppearanceState(const char *state) {
 
   Object obj1;
   obj1.initName(state);
-  update ("AS", &obj1);
+  update ("AS", &obj1, gFalse);
 
   // The appearance state determines the current appearance stream
   appearance.free();
@@ -1472,21 +1501,24 @@ void Annot::setAppearanceState(const char *state) {
   } else {
     appearance.initNull();
   }
+  if (lock) unlockAnnot;
 }
 
 void Annot::invalidateAppearance() {
+  lockAnnot;
   if (appearStreams) { // Remove existing appearance streams
     appearStreams->removeAllStreams();
   }
   delete appearStreams;
   appearStreams = NULL;
 
-  setAppearanceState("Off"); // Default appearance state
+  setAppearanceState("Off", gFalse); // Default appearance state
 
   Object obj1;
   obj1.initNull();
-  update ("AP", &obj1); // Remove AP
-  update ("AS", &obj1); // Remove AS
+  update ("AP", &obj1, gFalse); // Remove AP
+  update ("AS", &obj1, gFalse); // Remove AS
+  unlockAnnot;
 }
 
 double Annot::getXMin() {
@@ -1516,12 +1548,19 @@ void Annot::removeReferencedObjects() {
 }
 
 void Annot::incRefCnt() {
+  lockAnnot;
   refCnt++;
+  unlockAnnot;
 }
 
 void Annot::decRefCnt() {
-  if (--refCnt == 0)
+  lockAnnot;
+  if (--refCnt == 0) {
+    unlockAnnot;
     delete this;
+    return;
+  }
+  unlockAnnot;
 }
 
 Annot::~Annot() {
@@ -1552,6 +1591,10 @@ Annot::~Annot() {
     delete color;
 
   oc.free();
+
+#if MULTITHREADED
+    gDestroyMutex(&mutex);
+#endif
 }
 
 void Annot::setColor(AnnotColor *color, GBool fill) {
@@ -1744,6 +1787,7 @@ GBool Annot::isVisible(GBool printing) {
 void Annot::draw(Gfx *gfx, GBool printing) {
   Object obj;
 
+  lockAnnot;
   if (!isVisible (printing))
     return;
 
@@ -1752,6 +1796,7 @@ void Annot::draw(Gfx *gfx, GBool printing) {
   gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color,
       rect->x1, rect->y1, rect->x2, rect->y2);
   obj.free();
+  unlockAnnot;
 }
 
 //------------------------------------------------------------------------
@@ -2361,6 +2406,7 @@ void AnnotText::draw(Gfx *gfx, GBool printing) {
   if (!isVisible (printing))
     return;
 
+  lockAnnot;
   if (appearance.isNull()) {
     ca = opacity;
 
@@ -2422,6 +2468,7 @@ void AnnotText::draw(Gfx *gfx, GBool printing) {
                    rect->x1, rect->y1, rect->x2, rect->y2);
   }
   obj.free();
+  unlockAnnot;
 }
 
 //------------------------------------------------------------------------
@@ -2510,11 +2557,13 @@ void AnnotLink::draw(Gfx *gfx, GBool printing) {
   if (!isVisible (printing))
     return;
 
+  lockAnnot;
   // draw the appearance stream
   appearance.fetch(gfx->getXRef(), &obj);
   gfx->drawAnnot(&obj, border, color,
 		 rect->x1, rect->y1, rect->x2, rect->y2);
   obj.free();
+  unlockAnnot;
 }
 
 //------------------------------------------------------------------------
@@ -2939,6 +2988,7 @@ void AnnotFreeText::draw(Gfx *gfx, GBool printing) {
   if (!isVisible (printing))
     return;
 
+  lockAnnot;
   if (appearance.isNull()) {
     generateFreeTextAppearance();
   }
@@ -2948,6 +2998,7 @@ void AnnotFreeText::draw(Gfx *gfx, GBool printing) {
   gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color,
                  rect->x1, rect->y1, rect->x2, rect->y2);
   obj.free();
+  unlockAnnot;
 }
 
 // Before retrieving the res dict, regenerate the appearance stream if needed,
@@ -3411,6 +3462,7 @@ void AnnotLine::draw(Gfx *gfx, GBool printing) {
   if (!isVisible (printing))
     return;
 
+  lockAnnot;
   if (appearance.isNull()) {
     generateLineAppearance();
   }
@@ -3426,6 +3478,7 @@ void AnnotLine::draw(Gfx *gfx, GBool printing) {
                    rect->x1, rect->y1, rect->x2, rect->y2);
   }
   obj.free();
+  unlockAnnot;
 }
 
 // Before retrieving the res dict, regenerate the appearance stream if needed,
@@ -3576,6 +3629,7 @@ void AnnotTextMarkup::draw(Gfx *gfx, GBool printing) {
   if (!isVisible (printing))
     return;
 
+  lockAnnot;
   if (appearance.isNull() || type == typeHighlight) {
     GBool blendMultiply = gTrue;
     ca = opacity;
@@ -3734,6 +3788,7 @@ void AnnotTextMarkup::draw(Gfx *gfx, GBool printing) {
                    rect->x1, rect->y1, rect->x2, rect->y2);
   }
   obj.free();
+  unlockAnnot;
 }
 
 //------------------------------------------------------------------------
@@ -4956,6 +5011,7 @@ void AnnotWidget::draw(Gfx *gfx, GBool printing) {
   if (!isVisible (printing))
     return;
 
+  lockAnnot;
   addDingbatsResource = gFalse;
 
   // Only construct the appearance stream when
@@ -4999,6 +5055,7 @@ void AnnotWidget::draw(Gfx *gfx, GBool printing) {
     gfx->popResources();
   }
   obj.free();
+  unlockAnnot;
 }
 
 
@@ -5068,6 +5125,7 @@ void AnnotMovie::draw(Gfx *gfx, GBool printing) {
   if (!isVisible (printing))
     return;
 
+  lockAnnot;
   if (appearance.isNull() && movie->getShowPoster()) {
     int width, height;
     Object poster;
@@ -5151,6 +5209,7 @@ void AnnotMovie::draw(Gfx *gfx, GBool printing) {
   gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color,
 		 rect->x1, rect->y1, rect->x2, rect->y2);
   obj.free();
+  unlockAnnot;
 }
 
 //------------------------------------------------------------------------
@@ -5376,6 +5435,7 @@ void AnnotGeometry::draw(Gfx *gfx, GBool printing) {
   if (!isVisible (printing))
     return;
 
+  lockAnnot;
   if (appearance.isNull()) {
     ca = opacity;
 
@@ -5493,6 +5553,7 @@ void AnnotGeometry::draw(Gfx *gfx, GBool printing) {
   gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color,
 		 rect->x1, rect->y1, rect->x2, rect->y2);
   obj.free();
+  unlockAnnot;
 }
 
 //------------------------------------------------------------------------
@@ -5697,6 +5758,7 @@ void AnnotPolygon::draw(Gfx *gfx, GBool printing) {
   if (!isVisible (printing))
     return;
 
+  lockAnnot;
   if (appearance.isNull()) {
     appearBBox = new AnnotAppearanceBBox(rect);
     ca = opacity;
@@ -5783,6 +5845,7 @@ void AnnotPolygon::draw(Gfx *gfx, GBool printing) {
                    rect->x1, rect->y1, rect->x2, rect->y2);
   }
   obj.free();
+  unlockAnnot;
 }
 
 //------------------------------------------------------------------------
@@ -5934,6 +5997,7 @@ void AnnotInk::draw(Gfx *gfx, GBool printing) {
   if (!isVisible (printing))
     return;
 
+  lockAnnot;
   if (appearance.isNull()) {
     appearBBox = new AnnotAppearanceBBox(rect);
     ca = opacity;
@@ -5995,6 +6059,7 @@ void AnnotInk::draw(Gfx *gfx, GBool printing) {
                    rect->x1, rect->y1, rect->x2, rect->y2);
   }
   obj.free();
+  unlockAnnot;
 }
 
 //------------------------------------------------------------------------
@@ -6166,6 +6231,7 @@ void AnnotFileAttachment::draw(Gfx *gfx, GBool printing) {
   if (!isVisible (printing))
     return;
 
+  lockAnnot;
   if (appearance.isNull()) {
     ca = opacity;
 
@@ -6210,6 +6276,7 @@ void AnnotFileAttachment::draw(Gfx *gfx, GBool printing) {
   gfx->drawAnnot(&obj, border, color,
 		 rect->x1, rect->y1, rect->x2, rect->y2);
   obj.free();
+  unlockAnnot;
 }
 
 //------------------------------------------------------------------------
@@ -6332,6 +6399,7 @@ void AnnotSound::draw(Gfx *gfx, GBool printing) {
   if (!isVisible (printing))
     return;
 
+  lockAnnot;
   if (appearance.isNull()) {
     ca = opacity;
 
@@ -6371,6 +6439,7 @@ void AnnotSound::draw(Gfx *gfx, GBool printing) {
   gfx->drawAnnot(&obj, border, color,
 		 rect->x1, rect->y1, rect->x2, rect->y2);
   obj.free();
+  unlockAnnot;
 }
 
 //------------------------------------------------------------------------
diff --git a/poppler/Annot.h b/poppler/Annot.h
index 68ddeb7..65b8eac 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -24,6 +24,7 @@
 // Copyright (C) 2009-2011 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2012 Fabio D'Urso <fabiodurso at hotmail.it>
 // Copyright (C) 2012 Tobias Koenig <tokoe at kdab.com>
+// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag at alfa.de>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -571,7 +572,7 @@ public:
   // new_color. 
   void setColor(AnnotColor *new_color);
 
-  void setAppearanceState(const char *state);
+  void setAppearanceState(const char *state, GBool lock = gTrue);
 
   // Delete appearance streams and reset appearance state
   void invalidateAppearance();
@@ -626,7 +627,7 @@ protected:
 
   // Updates the field key of the annotation dictionary
   // and sets M to the current time
-  void update(const char *key, Object *value);
+  void update(const char *key, Object *value, GBool lock = gTrue);
 
   int refCnt;
 
@@ -660,6 +661,9 @@ protected:
   GBool ok;
 
   bool hasRef;
+#if MULTITHREADED
+  GooMutex mutex;
+#endif
 };
 
 //------------------------------------------------------------------------
diff --git a/poppler/FontInfo.cc b/poppler/FontInfo.cc
index 35d5f5f..d33226e 100644
--- a/poppler/FontInfo.cc
+++ b/poppler/FontInfo.cc
@@ -9,7 +9,7 @@
 // Copyright (C) 2009 Pino Toscano <pino at kde.org>
 // Copyright (C) 2010 Hib Eris <hib at hiberis.nl>
 // Copyright (C) 2010, 2012 Adrian Johnson <ajohnson at redneon.com>
-// Copyright (C) 2010 Thomas Freitag <Thomas.Freitag at alfa.de>
+// Copyright (C) 2010, 2013 Thomas Freitag <Thomas.Freitag at alfa.de>
 // Copyright (C) 2011 Carlos Garcia Campos <carlosgc at gnome.org>
 // Copyright (C) 2012 Fabio D'Urso <fabiodurso at hotmail.it>
 //
@@ -68,17 +68,19 @@ GooList *FontInfoScanner::scan(int nPages) {
     lastPage = doc->getNumPages() + 1;
   }
 
+  XRef *xrefA = doc->getXRef()->copy();
   for (int pg = currentPage; pg < lastPage; ++pg) {
     page = doc->getPage(pg);
     if (!page) continue;
 
-    if ((resDict = page->getResourceDict())) {
-      scanFonts(resDict, result);
+    if ((resDict = page->getResourceDict(xrefA))) {
+      scanFonts(xrefA, resDict, result);
+      delete resDict;
     }
     annots = page->getAnnots();
     for (int i = 0; i < annots->getNumAnnots(); ++i) {
       if (annots->getAnnot(i)->getAppearanceResDict(&obj1)->isDict()) {
-        scanFonts(obj1.getDict(), result);
+        scanFonts(xrefA, obj1.getDict(), result);
       }
       obj1.free();
     }
@@ -86,10 +88,11 @@ GooList *FontInfoScanner::scan(int nPages) {
 
   currentPage = lastPage;
 
+  delete xrefA;
   return result;
 }
 
-void FontInfoScanner::scanFonts(Dict *resDict, GooList *fontsList) {
+void FontInfoScanner::scanFonts(XRef *xrefA, Dict *resDict, GooList *fontsList) {
   Object obj1, obj2, objDict, resObj;
   Ref r;
   GfxFontDict *gfxFontDict;
@@ -100,14 +103,14 @@ void FontInfoScanner::scanFonts(Dict *resDict, GooList *fontsList) {
   gfxFontDict = NULL;
   resDict->lookupNF("Font", &obj1);
   if (obj1.isRef()) {
-    obj1.fetch(doc->getXRef(), &obj2);
+    obj1.fetch(xrefA, &obj2);
     if (obj2.isDict()) {
       r = obj1.getRef();
-      gfxFontDict = new GfxFontDict(doc->getXRef(), &r, obj2.getDict());
+      gfxFontDict = new GfxFontDict(xrefA, &r, obj2.getDict());
     }
     obj2.free();
   } else if (obj1.isDict()) {
-    gfxFontDict = new GfxFontDict(doc->getXRef(), NULL, obj1.getDict());
+    gfxFontDict = new GfxFontDict(xrefA, NULL, obj1.getDict());
   }
   if (gfxFontDict) {
     for (i = 0; i < gfxFontDict->getNumFonts(); ++i) {
@@ -116,7 +119,7 @@ void FontInfoScanner::scanFonts(Dict *resDict, GooList *fontsList) {
 
         // add this font to the list if not already found
         if (fonts.find(fontRef.num) == fonts.end()) {
-          fontsList->append(new FontInfo(font, doc));
+          fontsList->append(new FontInfo(font, xrefA));
           fonts.insert(fontRef.num);
         }
       }
@@ -144,12 +147,12 @@ void FontInfoScanner::scanFonts(Dict *resDict, GooList *fontsList) {
           visitedObjects.insert(r.num);
         }
 
-        obj1.fetch(doc->getXRef(), &obj2);
+        obj1.fetch(xrefA, &obj2);
 
         if (obj2.isStream()) {
           obj2.streamGetDict()->lookup("Resources", &resObj);
           if (resObj.isDict() && resObj.getDict() != resDict) {
-            scanFonts(resObj.getDict(), fontsList);
+            scanFonts(xrefA, resObj.getDict(), fontsList);
           }
           resObj.free();
         }
@@ -161,7 +164,7 @@ void FontInfoScanner::scanFonts(Dict *resDict, GooList *fontsList) {
   }
 }
 
-FontInfo::FontInfo(GfxFont *font, PDFDoc *doc) {
+FontInfo::FontInfo(GfxFont *font, XRef *xref) {
   GooString *origName;
   Object fontObj, toUnicodeObj;
   int i;
@@ -201,7 +204,7 @@ FontInfo::FontInfo(GfxFont *font, PDFDoc *doc) {
 
   // look for a ToUnicode map
   hasToUnicode = gFalse;
-  if (doc->getXRef()->fetch(fontRef.num, fontRef.gen, &fontObj)->isDict()) {
+  if (xref->fetch(fontRef.num, fontRef.gen, &fontObj)->isDict()) {
     hasToUnicode = fontObj.dictLookup("ToUnicode", &toUnicodeObj)->isStream();
     toUnicodeObj.free();
   }
diff --git a/poppler/FontInfo.h b/poppler/FontInfo.h
index db90440..615b679 100644
--- a/poppler/FontInfo.h
+++ b/poppler/FontInfo.h
@@ -7,6 +7,7 @@
 // Copyright (C) 2005 Brad Hards <bradh at frogmouth.net>
 // Copyright (C) 2009 Pino Toscano <pino at kde.org>
 // Copyright (C) 2012 Adrian Johnson <ajohnson at redneon.com>
+// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag at alfa.de>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -49,7 +50,7 @@ public:
   };
     
   // Constructor.
-  FontInfo(GfxFont *fontA, PDFDoc *doc);
+  FontInfo(GfxFont *fontA, XRef *xrefA);
   // Copy constructor
   FontInfo(FontInfo& f);
   // Destructor.
@@ -96,7 +97,7 @@ private:
   std::set<int> fonts;
   std::set<int> visitedObjects;
 
-  void scanFonts(Dict *resDict, GooList *fontsList);
+  void scanFonts(XRef *xrefA, Dict *resDict, GooList *fontsList);
 };
 
 #endif
diff --git a/poppler/Page.cc b/poppler/Page.cc
index fa6d2a9..96040d8 100644
--- a/poppler/Page.cc
+++ b/poppler/Page.cc
@@ -359,6 +359,13 @@ Page::~Page() {
 #endif
 }
 
+Dict *Page::getResourceDict(XRef *xrefA) { 
+  lockPage;
+  Dict *dict = (xrefA == NULL) ? attrs->getResourceDict() : attrs->getResourceDict()->copy(xrefA); 
+  unlockPage;
+  return dict;
+}
+
 void Page::replaceXRef(XRef *xrefA) {
   Object obj1;
   Dict *pageDict = pageObj.getDict()->copy(xrefA);
@@ -386,10 +393,10 @@ void Page::replaceXRef(XRef *xrefA) {
   delete pageDict;
 }
 
-Annots *Page::getAnnots() {
+Annots *Page::getAnnots(XRef *xrefA) {
   if (!annots) {
     Object obj;
-    annots = new Annots(doc, num, getAnnots(&obj));
+    annots = new Annots(doc, num, getAnnots(&obj, (xrefA == NULL) ? xref : xrefA));
     obj.free();
   }
 
diff --git a/poppler/Page.h b/poppler/Page.h
index 100731d..464b030 100644
--- a/poppler/Page.h
+++ b/poppler/Page.h
@@ -174,10 +174,10 @@ public:
   Ref getRef() { return pageRef; }
 
   // Get resource dictionary.
-  Dict *getResourceDict() { return attrs->getResourceDict(); }
+  Dict *getResourceDict(XRef *xrefA = NULL);
 
   // Get annotations array.
-  Object *getAnnots(Object *obj) { return annotsObj.fetch(xref, obj); }
+  Object *getAnnots(Object *obj, XRef *xrefA = NULL) { return annotsObj.fetch((xrefA == NULL) ? xref : xrefA, obj); }
   // Add a new annotation to the page
   void addAnnot(Annot *annot);
   // Remove an existing annotation from the page
@@ -187,7 +187,7 @@ public:
   Links *getLinks();
 
   // Return a list of annots. It will be valid until the page is destroyed
-  Annots *getAnnots();
+  Annots *getAnnots(XRef *xrefA = NULL);
 
   // Get contents.
   Object *getContents(Object *obj) { return contents.fetch(xref, obj); }
diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc
index 31d6fce..c03b2f9 100644
--- a/poppler/SplashOutputDev.cc
+++ b/poppler/SplashOutputDev.cc
@@ -1211,7 +1211,9 @@ SplashOutputDev::SplashOutputDev(SplashColorMode colorModeA,
 				 GBool reverseVideoA,
 				 SplashColorPtr paperColorA,
 				 GBool bitmapTopDownA,
-				 GBool allowAntialiasA, SplashThinLineMode thinLineMode) {
+				 GBool allowAntialiasA, 
+         SplashThinLineMode thinLineMode,
+         GBool overprintPreviewA) {
   colorMode = colorModeA;
   bitmapRowPad = bitmapRowPadA;
   bitmapTopDown = bitmapTopDownA;
@@ -1220,6 +1222,7 @@ SplashOutputDev::SplashOutputDev(SplashColorMode colorModeA,
   vectorAntialias = allowAntialias &&
 		      globalParams->getVectorAntialias() &&
 		      colorMode != splashModeMono1;
+  overprintPreview = overprintPreviewA;
   enableFreeTypeHinting = gFalse;
   enableSlightHinting = gFalse;
   setupScreenParams(72.0, 72.0);
@@ -1674,7 +1677,7 @@ void SplashOutputDev::setOverprintMask(GfxColorSpace *colorSpace,
 		     grayIndexed);
 		return;
 	}
-  if (overprintFlag && globalParams->getOverprintPreview()) {
+  if (overprintFlag && overprintPreview) {
     mask = colorSpace->getOverprintMask();
     if (singleColor && overprintMode &&
 	colorSpace->getMode() == csDeviceCMYK) {
diff --git a/poppler/SplashOutputDev.h b/poppler/SplashOutputDev.h
index d9fdd29..ce1d50d 100644
--- a/poppler/SplashOutputDev.h
+++ b/poppler/SplashOutputDev.h
@@ -40,6 +40,7 @@
 #include "poppler-config.h"
 #include "OutputDev.h"
 #include "GfxState.h"
+#include "GlobalParams.h"
 
 class PDFDoc;
 class Gfx8BitFont;
@@ -164,7 +165,8 @@ public:
 		  GBool reverseVideoA, SplashColorPtr paperColorA,
 		  GBool bitmapTopDownA = gTrue,
 		  GBool allowAntialiasA = gTrue,
-		  SplashThinLineMode thinLineMode = splashThinLineDefault);
+		  SplashThinLineMode thinLineMode = splashThinLineDefault,
+      GBool overprintPreviewA = globalParams->getOverprintPreview());
 
   // Destructor.
   virtual ~SplashOutputDev();
@@ -390,6 +392,7 @@ private:
   GBool bitmapUpsideDown;
   GBool allowAntialias;
   GBool vectorAntialias;
+  GBool overprintPreview;
   GBool enableFreeTypeHinting;
   GBool enableSlightHinting;
   GBool reverseVideo;		// reverse video mode
diff --git a/poppler/XRef.cc b/poppler/XRef.cc
index e2e86ad..c0d37d0 100644
--- a/poppler/XRef.cc
+++ b/poppler/XRef.cc
@@ -1396,8 +1396,10 @@ void XRef::removeIndirectObject(Ref r) {
     return;
   }
   XRefEntry *e = getEntry(r.num);
-  if (e->type == xrefEntryFree)
+  if (e->type == xrefEntryFree) {
+    unlockXRef;
     return;
+  }
   e->obj.free();
   e->type = xrefEntryFree;
   e->gen++;
diff --git a/qt4/src/poppler-page.cc b/qt4/src/poppler-page.cc
index f9ac443..7c47573 100644
--- a/qt4/src/poppler-page.cc
+++ b/qt4/src/poppler-page.cc
@@ -229,7 +229,8 @@ TextPage *PageData::prepareTextSearch(const QString &text, Page::SearchMode case
 
   // fetch ourselves a textpage
   TextOutputDev td(NULL, gTrue, 0, gFalse, gFalse);
-  parentDoc->doc->displayPage( &td, index + 1, 72, 72, rotation, false, true, false );
+  parentDoc->doc->displayPage( &td, index + 1, 72, 72, rotation, false, true, false,
+    NULL, NULL, NULL, NULL, gTrue);
   TextPage *textPage=td.takeText();
   
   return textPage;
@@ -259,9 +260,9 @@ QImage Page::renderToImage(double xres, double yres, int x, int y, int w, int h,
     {
 #if defined(HAVE_SPLASH)
       SplashColor bgColor;
+      GBool overprint = gFalse;
 #if defined(SPLASH_CMYK)
-      GBool overprint = m_page->parentDoc->m_hints & Document::OverprintPreview ? gTrue : gFalse;
-      globalParams->setOverprintPreview(overprint);
+      overprint = m_page->parentDoc->m_hints & Document::OverprintPreview ? gTrue : gFalse;
       if (overprint)
       {
         Guchar c, m, y, k;
@@ -300,7 +301,7 @@ QImage Page::renderToImage(double xres, double yres, int x, int y, int w, int h,
 #else
                       splashModeXBGR8,
 #endif 
-                      4, gFalse, bgColor, gTrue, AA);
+                      4, gFalse, bgColor, gTrue, AA, splashThinLineDefault, overprint);
 
       splash_output->setVectorAntialias(m_page->parentDoc->m_hints & Document::Antialiasing ? gTrue : gFalse);
       splash_output->setFreeTypeHinting(m_page->parentDoc->m_hints & Document::TextHinting ? gTrue : gFalse, 
diff --git a/qt4/src/poppler-ps-converter.cc b/qt4/src/poppler-ps-converter.cc
index 63fb7b4..ff8af65 100644
--- a/qt4/src/poppler-ps-converter.cc
+++ b/qt4/src/poppler-ps-converter.cc
@@ -4,6 +4,7 @@
  * Copyright (C) 2010 Hib Eris <hib at hiberis.nl>
  * Copyright (C) 2011 Glad Deschrijver <glad.deschrijver at gmail.com>
  * Copyright (C) 2012 Fabio D'Urso <fabiodurso at hotmail.it>
+ * Copyright (C) 2013 Thomas Freitag <Thomas.Freitag at alfa.de>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -253,7 +254,7 @@ bool PSConverter::convert()
 			                              NULL,
 			                              NULL,
 			                              annotDisplayDecideCbk,
-			                              &showAnnotations);
+			                              &showAnnotations, gTrue);
 			if (d->pageConvertedCallback)
 				(*d->pageConvertedCallback)(page, d->pageConvertedPayload);
 		}


More information about the poppler mailing list