Commit 677e5b26 authored by Albert Astals Cid's avatar Albert Astals Cid

Small improvements over locker class

 * Remove the namespace (we don't use much/any namespaces in poppler core)
 * Rename the class and defines from lock to locker since lock and be either the action "to lock" or the "thing that locks", with locker it is more clear (i think) that is "the thing" than "the action"
 * Make Annot::decRefCnt use gLockMutex since we the object itself is being deleted in the if and not sure the locker would be happy with that
 * change the getNumPages() param to be DoNotLockMutex since previously it was a gFalse (i guess Thomas made a c&p typo here)
 * Have only one constructor like Adam suggested.
parent d5c929fc
......@@ -16,6 +16,8 @@
// under GPL version 2 or later
//
// Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net>
// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2013 Albert Astals Cid <aacid@kde.org>
//
// 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
......@@ -60,20 +62,19 @@ typedef pthread_mutex_t GooMutex;
#endif
namespace Poppler {
enum LockMode {
DoNotLock, // for conditional locks: do not lock
DoLock // for conditional locks: do lock
};
class Lock {
public:
Lock(GooMutex *mutexA) : mutex(mutexA) { mode = DoLock; gLockMutex(mutex); }
Lock(GooMutex *mutexA, LockMode modeA) : mutex(mutexA) { mode = modeA; if (mode == DoLock) gLockMutex(mutex); }
~Lock() { if (mode == DoLock) gUnlockMutex(mutex); }
private:
GooMutex *mutex;
LockMode mode;
};
}
enum MutexLockMode {
DoNotLockMutex, // for conditional locks: do not lock
DoLockMutex // for conditional locks: do lock
};
class MutexLocker {
public:
MutexLocker(GooMutex *mutexA, MutexLockMode modeA = DoLockMutex) : mutex(mutexA), mode(modeA) { if (mode == DoLockMutex) gLockMutex(mutex); }
~MutexLocker() { if (mode == DoLockMutex) gUnlockMutex(mutex); }
private:
GooMutex *mutex;
const MutexLockMode mode;
};
#endif
......@@ -15,7 +15,7 @@
//
// Copyright (C) 2006 Scott Turner <scotty1024@mac.com>
// Copyright (C) 2007, 2008 Julien Rebetez <julienr@svn.gnome.org>
// Copyright (C) 2007-2012 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2007-2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2007-2012 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright (C) 2007, 2008 Iñigo Martínez <inigomartinez@gmail.com>
// Copyright (C) 2007 Jeff Muizelaar <jeff@infidigm.net>
......@@ -68,11 +68,11 @@
#include <string.h>
#if MULTITHREADED
# define lockAnnot() Poppler::Lock lock(&mutex)
# define condLockAnnot(X) Poppler::Lock condlock(&mutex, (X))
# define annotLocker() MutexLocker locker(&mutex)
# define annotCondLocker(X) MutexLocker locker(&mutex, (X))
#else
# define lockAnnot()
# define condLockAnnot(X)
# define annotLocker()
# define annotCondLocker(X)
#endif
#define fieldFlagReadOnly 0x00000001
......@@ -1213,7 +1213,7 @@ void Annot::initialize(PDFDoc *docA, Dict *dict) {
if (dict->lookupNF("P", &obj1)->isRef()) {
Ref ref = obj1.getRef();
page = doc->getCatalog()->findPage (ref.num, ref.gen, Poppler::DoNotLock);
page = doc->getCatalog()->findPage (ref.num, ref.gen, DoNotLockMutex);
} else {
page = 0;
}
......@@ -1350,8 +1350,8 @@ GBool Annot::inRect(double x, double y) const {
return rect->contains(x, y);
}
void Annot::update(const char *key, Object *value, Poppler::LockMode lock) {
condLockAnnot(lock);
void Annot::update(const char *key, Object *value, MutexLockMode lock) {
annotCondLocker(lock);
/* Set M to current time, unless we are updating M itself */
if (strcmp(key, "M") != 0) {
delete modified;
......@@ -1368,7 +1368,7 @@ void Annot::update(const char *key, Object *value, Poppler::LockMode lock) {
}
void Annot::setContents(GooString *new_content) {
lockAnnot();
annotLocker();
delete contents;
if (new_content) {
......@@ -1384,11 +1384,11 @@ void Annot::setContents(GooString *new_content) {
Object obj1;
obj1.initString(contents->copy());
update ("Contents", &obj1, Poppler::DoNotLock);
update ("Contents", &obj1, DoNotLockMutex);
}
void Annot::setName(GooString *new_name) {
lockAnnot();
annotLocker();
delete name;
if (new_name) {
......@@ -1399,11 +1399,11 @@ void Annot::setName(GooString *new_name) {
Object obj1;
obj1.initString(name->copy());
update ("NM", &obj1, Poppler::DoNotLock);
update ("NM", &obj1, DoNotLockMutex);
}
void Annot::setModified(GooString *new_modified) {
lockAnnot();
annotLocker();
delete modified;
if (new_modified)
......@@ -1413,25 +1413,25 @@ void Annot::setModified(GooString *new_modified) {
Object obj1;
obj1.initString(modified->copy());
update ("M", &obj1, Poppler::DoNotLock);
update ("M", &obj1, DoNotLockMutex);
}
void Annot::setFlags(Guint new_flags) {
lockAnnot();
annotLocker();
Object obj1;
flags = new_flags;
obj1.initInt(flags);
update ("F", &obj1, Poppler::DoNotLock);
update ("F", &obj1, DoNotLockMutex);
}
void Annot::setBorder(AnnotBorderArray *new_border) {
lockAnnot();
annotLocker();
delete border;
if (new_border) {
Object obj1;
new_border->writeToObject(xref, &obj1);
update ("Border", &obj1, Poppler::DoNotLock);
update ("Border", &obj1, DoNotLockMutex);
border = new_border;
} else {
border = NULL;
......@@ -1439,13 +1439,13 @@ void Annot::setBorder(AnnotBorderArray *new_border) {
}
void Annot::setColor(AnnotColor *new_color) {
lockAnnot();
annotLocker();
delete color;
if (new_color) {
Object obj1;
new_color->writeToObject(xref, &obj1);
update ("C", &obj1, Poppler::DoNotLock);
update ("C", &obj1, DoNotLockMutex);
color = new_color;
} else {
color = NULL;
......@@ -1453,7 +1453,7 @@ void Annot::setColor(AnnotColor *new_color) {
}
void Annot::setPage(int pageIndex, GBool updateP) {
lockAnnot();
annotLocker();
Page *pageobj = doc->getPage(pageIndex);
Object obj1;
......@@ -1467,12 +1467,12 @@ void Annot::setPage(int pageIndex, GBool updateP) {
}
if (updateP) {
update("P", &obj1, Poppler::DoNotLock);
update("P", &obj1, DoNotLockMutex);
}
}
void Annot::setAppearanceState(const char *state, Poppler::LockMode lock) {
condLockAnnot(lock);
void Annot::setAppearanceState(const char *state, MutexLockMode lock) {
annotCondLocker(lock);
if (!state)
return;
......@@ -1484,7 +1484,7 @@ void Annot::setAppearanceState(const char *state, Poppler::LockMode lock) {
Object obj1;
obj1.initName(state);
update ("AS", &obj1, Poppler::DoNotLock);
update ("AS", &obj1, DoNotLockMutex);
// The appearance state determines the current appearance stream
appearance.free();
......@@ -1496,19 +1496,19 @@ void Annot::setAppearanceState(const char *state, Poppler::LockMode lock) {
}
void Annot::invalidateAppearance() {
lockAnnot();
annotLocker();
if (appearStreams) { // Remove existing appearance streams
appearStreams->removeAllStreams();
}
delete appearStreams;
appearStreams = NULL;
setAppearanceState("Off", Poppler::DoNotLock); // Default appearance state
setAppearanceState("Off", DoNotLockMutex); // Default appearance state
Object obj1;
obj1.initNull();
update ("AP", &obj1, Poppler::DoNotLock); // Remove AP
update ("AS", &obj1, Poppler::DoNotLock); // Remove AS
update ("AP", &obj1, DoNotLockMutex); // Remove AP
update ("AS", &obj1, DoNotLockMutex); // Remove AS
}
double Annot::getXMin() {
......@@ -1538,16 +1538,18 @@ void Annot::removeReferencedObjects() {
}
void Annot::incRefCnt() {
lockAnnot();
annotLocker();
refCnt++;
}
void Annot::decRefCnt() {
lockAnnot();
gLockMutex(&mutex);
if (--refCnt == 0) {
gUnlockMutex(&mutex);
delete this;
return;
}
gUnlockMutex(&mutex);
}
Annot::~Annot() {
......@@ -1774,7 +1776,7 @@ GBool Annot::isVisible(GBool printing) {
void Annot::draw(Gfx *gfx, GBool printing) {
Object obj;
lockAnnot();
annotLocker();
if (!isVisible (printing))
return;
......@@ -2392,7 +2394,7 @@ void AnnotText::draw(Gfx *gfx, GBool printing) {
if (!isVisible (printing))
return;
lockAnnot();
annotLocker();
if (appearance.isNull()) {
ca = opacity;
......@@ -2542,7 +2544,7 @@ void AnnotLink::draw(Gfx *gfx, GBool printing) {
if (!isVisible (printing))
return;
lockAnnot();
annotLocker();
// draw the appearance stream
appearance.fetch(gfx->getXRef(), &obj);
gfx->drawAnnot(&obj, border, color,
......@@ -2972,7 +2974,7 @@ void AnnotFreeText::draw(Gfx *gfx, GBool printing) {
if (!isVisible (printing))
return;
lockAnnot();
annotLocker();
if (appearance.isNull()) {
generateFreeTextAppearance();
}
......@@ -3445,7 +3447,7 @@ void AnnotLine::draw(Gfx *gfx, GBool printing) {
if (!isVisible (printing))
return;
lockAnnot();
annotLocker();
if (appearance.isNull()) {
generateLineAppearance();
}
......@@ -3611,7 +3613,7 @@ void AnnotTextMarkup::draw(Gfx *gfx, GBool printing) {
if (!isVisible (printing))
return;
lockAnnot();
annotLocker();
if (appearance.isNull() || type == typeHighlight) {
GBool blendMultiply = gTrue;
ca = opacity;
......@@ -3811,7 +3813,7 @@ AnnotWidget::~AnnotWidget() {
void AnnotWidget::initialize(PDFDoc *docA, Dict *dict) {
Object obj1;
form = doc->getCatalog()->getForm(Poppler::DoNotLock);
form = doc->getCatalog()->getForm(DoNotLockMutex);
if(dict->lookup("H", &obj1)->isName()) {
const char *modeName = obj1.getName();
......@@ -4997,7 +4999,7 @@ void AnnotWidget::draw(Gfx *gfx, GBool printing) {
if (!isVisible (printing))
return;
lockAnnot();
annotLocker();
addDingbatsResource = gFalse;
// Only construct the appearance stream when
......@@ -5110,7 +5112,7 @@ void AnnotMovie::draw(Gfx *gfx, GBool printing) {
if (!isVisible (printing))
return;
lockAnnot();
annotLocker();
if (appearance.isNull() && movie->getShowPoster()) {
int width, height;
Object poster;
......@@ -5419,7 +5421,7 @@ void AnnotGeometry::draw(Gfx *gfx, GBool printing) {
if (!isVisible (printing))
return;
lockAnnot();
annotLocker();
if (appearance.isNull()) {
ca = opacity;
......@@ -5741,7 +5743,7 @@ void AnnotPolygon::draw(Gfx *gfx, GBool printing) {
if (!isVisible (printing))
return;
lockAnnot();
annotLocker();
if (appearance.isNull()) {
appearBBox = new AnnotAppearanceBBox(rect);
ca = opacity;
......@@ -5979,7 +5981,7 @@ void AnnotInk::draw(Gfx *gfx, GBool printing) {
if (!isVisible (printing))
return;
lockAnnot();
annotLocker();
if (appearance.isNull()) {
appearBBox = new AnnotAppearanceBBox(rect);
ca = opacity;
......@@ -6212,7 +6214,7 @@ void AnnotFileAttachment::draw(Gfx *gfx, GBool printing) {
if (!isVisible (printing))
return;
lockAnnot();
annotLocker();
if (appearance.isNull()) {
ca = opacity;
......@@ -6379,7 +6381,7 @@ void AnnotSound::draw(Gfx *gfx, GBool printing) {
if (!isVisible (printing))
return;
lockAnnot();
annotLocker();
if (appearance.isNull()) {
ca = opacity;
......
......@@ -21,7 +21,7 @@
// Copyright (C) 2008 Hugo Mercier <hmercier31@gmail.com>
// Copyright (C) 2008 Pino Toscano <pino@kde.org>
// Copyright (C) 2008 Tomas Are Haavet <tomasare@gmail.com>
// Copyright (C) 2009-2011 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2009-2011, 2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it>
// Copyright (C) 2012 Tobias Koenig <tokoe@kdab.com>
// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
......@@ -572,7 +572,7 @@ public:
// new_color.
void setColor(AnnotColor *new_color);
void setAppearanceState(const char *state, Poppler::LockMode lock = Poppler::DoLock);
void setAppearanceState(const char *state, MutexLockMode lock = DoLockMutex);
// Delete appearance streams and reset appearance state
void invalidateAppearance();
......@@ -627,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, Poppler::LockMode lock = Poppler::DoLock);
void update(const char *key, Object *value, MutexLockMode lock = DoLockMutex);
int refCnt;
......
......@@ -16,6 +16,7 @@
// Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it>
// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2013 Albert Astals Cid <aacid@kde.org>
//
// 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
......@@ -35,9 +36,9 @@
#include "Array.h"
#if MULTITHREADED
# define lockArray() Poppler::Lock lock(&mutex)
# define arrayLocker() MutexLocker locker(&mutex)
#else
# define lockArray()
# define arrayLocker()
#endif
//------------------------------------------------------------------------
// Array
......@@ -65,7 +66,7 @@ Array::~Array() {
}
Object *Array::copy(XRef *xrefA, Object *obj) {
lockArray();
arrayLocker();
obj->initArray(xrefA);
for (int i = 0; i < length; ++i) {
Object obj1;
......@@ -75,19 +76,19 @@ Object *Array::copy(XRef *xrefA, Object *obj) {
}
int Array::incRef() {
lockArray();
arrayLocker();
++ref;
return ref;
}
int Array::decRef() {
lockArray();
arrayLocker();
--ref;
return ref;
}
void Array::add(Object *elem) {
lockArray();
arrayLocker();
if (length == size) {
if (length == 0) {
size = 8;
......@@ -101,7 +102,7 @@ void Array::add(Object *elem) {
}
void Array::remove(int i) {
lockArray();
arrayLocker();
if (i < 0 || i >= length) {
#ifdef DEBUG_MEM
abort();
......
......@@ -17,7 +17,7 @@
// Copyright (C) 2005-2007 Jeff Muizelaar <jeff@infidigm.net>
// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org>
// Copyright (C) 2005, 2009, 2012 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2005, 2009, 2012, 2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2006, 2007, 2010, 2011 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright (C) 2007 Koji Otani <sho@bbr.jp>
// Copyright (C) 2008, 2009 Chris Wilson <chris@chris-wilson.co.uk>
......@@ -60,9 +60,9 @@
#endif
#if MULTITHREADED
# define lockFontEngine() Poppler::Lock lock(&mutex)
# define fontEngineLocker() MutexLocker locker(&mutex)
#else
# define lockFontEngine()
# define fontEngineLocker()
#endif
//------------------------------------------------------------------------
......@@ -787,7 +787,7 @@ CairoFontEngine::getFont(GfxFont *gfxFont, PDFDoc *doc, GBool printing, XRef *xr
CairoFont *font;
GfxFontType fontType;
lockFontEngine();
fontEngineLocker();
ref = *gfxFont->getID();
for (i = 0; i < cairoFontCacheSize; ++i) {
......
......@@ -14,7 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2005-2012 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2005-2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2005 Jeff Muizelaar <jrmuizel@nit.ca>
// Copyright (C) 2005 Jonathan Blandford <jrb@redhat.com>
// Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com>
......@@ -57,11 +57,11 @@
#include "FileSpec.h"
#if MULTITHREADED
# define lockCatalog() Poppler::Lock lock(&mutex)
# define condLockCatalog(X) Poppler::Lock condlock(&mutex, (X))
# define catalogLocker() MutexLocker locker(&mutex)
# define catalogCondLocker(X) MutexLocker locker(&mutex, (X))
#else
# define lockCatalog()
# define condLockCatalog(X)
# define catalogLocker()
# define catalogCondLocker(X)
#endif
//------------------------------------------------------------------------
// Catalog
......@@ -191,7 +191,7 @@ GooString *Catalog::readMetadata() {
Dict *dict;
Object obj;
lockCatalog();
catalogLocker();
if (metadata.isNone()) {
Object catDict;
......@@ -224,7 +224,7 @@ Page *Catalog::getPage(int i)
{
if (i < 1) return NULL;
lockCatalog();
catalogLocker();
if (i > lastCachedPage) {
GBool cached = cachePageTree(i);
if ( cached == gFalse) {
......@@ -234,11 +234,11 @@ Page *Catalog::getPage(int i)
return pages[i-1];
}
Ref *Catalog::getPageRef(int i, Poppler::LockMode lock)
Ref *Catalog::getPageRef(int i, MutexLockMode lock)
{
if (i < 1) return NULL;
condLockCatalog(lock);
catalogCondLocker(lock);
if (i > lastCachedPage) {
GBool cached = cachePageTree(i);
if ( cached == gFalse) {
......@@ -294,7 +294,7 @@ GBool Catalog::cachePageTree(int page)
return gFalse;
}
pagesSize = getNumPages(Poppler::DoNotLock);
pagesSize = getNumPages(DoNotLockMutex);
pages = (Page **)gmallocn(pagesSize, sizeof(Page *));
pageRefs = (Ref *)gmallocn(pagesSize, sizeof(Ref));
for (int i = 0; i < pagesSize; ++i) {
......@@ -421,7 +421,7 @@ GBool Catalog::cachePageTree(int page)
return gFalse;
}
int Catalog::findPage(int num, int gen, Poppler::LockMode lock) {
int Catalog::findPage(int num, int gen, MutexLockMode lock) {
int i;
for (i = 0; i < getNumPages(lock); ++i) {
......@@ -446,7 +446,7 @@ LinkDest *Catalog::findDest(GooString *name) {
obj1.free();
}
if (!found) {
lockCatalog();
catalogLocker();
if (getDestNameTree()->lookup(name, &obj1))
found = gTrue;
else
......@@ -481,7 +481,7 @@ FileSpec *Catalog::embeddedFile(int i)
{
Object efDict;
Object obj;
lockCatalog();
catalogLocker();
obj = getEmbeddedFileNameTree()->getValue(i);
FileSpec *embeddedFile = 0;
if (obj.isRef()) {
......@@ -502,7 +502,7 @@ GooString *Catalog::getJS(int i)
Object obj;
// getJSNameTree()->getValue(i) returns a shallow copy of the object so we
// do not need to free it
lockCatalog();
catalogLocker();
getJSNameTree()->getValue(i).fetch(xref, &obj);
if (!obj.isDict()) {
......@@ -538,7 +538,7 @@ GooString *Catalog::getJS(int i)
Catalog::PageMode Catalog::getPageMode() {
lockCatalog();
catalogLocker();
if (pageMode == pageModeNull) {
Object catDict, obj;
......@@ -574,7 +574,7 @@ Catalog::PageMode Catalog::getPageMode() {
Catalog::PageLayout Catalog::getPageLayout() {
lockCatalog();
catalogLocker();
if (pageLayout == pageLayoutNull) {
Object catDict, obj;
......@@ -772,9 +772,9 @@ GBool Catalog::indexToLabel(int index, GooString *label)
}
}
int Catalog::getNumPages(Poppler::LockMode lock)
int Catalog::getNumPages(MutexLockMode lock)
{
condLockCatalog((numPages == -1 && lock == Poppler::DoLock) ? lock : Poppler::DoNotLock);
catalogCondLocker((numPages == -1 && lock == DoLockMutex) ? DoLockMutex : DoNotLockMutex);
if (numPages == -1)
{
Object catDict, pagesDict, obj;
......@@ -816,7 +816,7 @@ int Catalog::getNumPages(Poppler::LockMode lock)
PageLabelInfo *Catalog::getPageLabelInfo()
{
lockCatalog();
catalogLocker();
if (!pageLabelInfo) {
Object catDict;
Object obj;
......@@ -829,7 +829,7 @@ PageLabelInfo *Catalog::getPageLabelInfo()
}
if (catDict.dictLookup("PageLabels", &obj)->isDict()) {
pageLabelInfo = new PageLabelInfo(&obj, getNumPages(Poppler::DoLock));
pageLabelInfo = new PageLabelInfo(&obj, getNumPages(DoNotLockMutex));
}
obj.free();
catDict.free();
......@@ -840,7 +840,7 @@ PageLabelInfo *Catalog::getPageLabelInfo()
Object *Catalog::getStructTreeRoot()
{
lockCatalog();
catalogLocker();
if (structTreeRoot.isNone())
{
Object catDict;
......@@ -860,7 +860,7 @@ Object *Catalog::getStructTreeRoot()
Object *Catalog::getOutline()
{
lockCatalog();
catalogLocker();
if (outline.isNone())
{
Object catDict;
......@@ -880,7 +880,7 @@ Object *Catalog::getOutline()
Object *Catalog::getDests()
{
lockCatalog();
catalogLocker();
if (dests.isNone())
{
Object catDict;
......@@ -916,9 +916,9 @@ Catalog::FormType Catalog::getFormType()
return res;
}
Form *Catalog::getForm(Poppler::LockMode lock)
Form *Catalog::getForm(MutexLockMode lock)
{
condLockCatalog(lock);
catalogCondLocker(lock);
if (!form) {
if (acroForm.isDict()) {
form = new Form(doc, &acroForm);
......@@ -932,7 +932,7 @@ Form *Catalog::getForm(Poppler::LockMode lock)
ViewerPreferences *Catalog::getViewerPreferences()
{
lockCatalog();
catalogLocker();
if (!viewerPrefs) {
if (viewerPreferences.isDict()) {
viewerPrefs = new ViewerPreferences(viewerPreferences.getDict());
......
......@@ -14,7 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2005, 2007, 2009-2011 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2005, 2007, 2009-2011, 2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2005 Jonathan Blandford <jrb@redhat.com>
// Copyright (C) 2005, 2006, 2008 Brad Hards <bradh@frogmouth.net>
// Copyright (C) 2007 Julien Rebetez <julienr@svn.gnome.org>
......@@ -107,13 +107,13 @@ public:
GBool isOk() { return ok; }
// Get number of pages.
int getNumPages(Poppler::LockMode lock = Poppler::DoLock);
int getNumPages(MutexLockMode lock = DoLockMutex);
// Get a page.
Page *getPage(int i);
// Get the reference for a page object.
Ref *getPageRef(int i, Poppler::LockMode lock = Poppler::DoLock);
Ref *getPageRef(int i, MutexLockMode lock = DoLockMutex);
// Return base URI, or NULL if none.
GooString *getBaseURI() { return baseURI; }
......@@ -127,7 +127,7 @@ public:
// Find a page, given its object ID. Returns page number, or 0 if
// not found.
int findPage(int num, int gen, Poppler::LockMode lock = Poppler::DoLock);
int findPage(int num, int gen, MutexLockMode lock = DoLockMutex);
// Find a named destination. Returns the link destination, or
// NULL if <name> is not a destination.
......@@ -165,7 +165,7 @@ public:
};
FormType getFormType();
Form* getForm(Poppler::LockMode lock = Poppler::DoLock);
Form* getForm(MutexLockMode lock = DoLockMutex);
ViewerPreferences *getViewerPreferences();
......
......@@ -16,7 +16,7 @@
// Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright (C) 2007-2008 Julien Rebetez <julienr@svn.gnome.org>
// Copyright (C) 2008, 2010 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2008, 2010, 2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2010 Paweł Wiejacha <pawel.wiejacha@gmail.com>
// Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it>
// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
......@@ -41,9 +41,9 @@
#include "Dict.h"
#if MULTITHREADED
# define lockDict() Poppler::Lock lock(&mutex)
# define dictLocker() MutexLocker locker(&mutex)
#else
# define lockDict()
# define dictLocker()
#endif
//------------------------------------------------------------------------
// Dict
......@@ -102,7 +102,7 @@ Dict::Dict(Dict* dictA) {
}
Dict *Dict::copy(XRef *xrefA) {
lockDict();
dictLocker();
Dict *dictA = new Dict(this);
dictA->xref = xrefA;
for (int i=0; i<length; i++) {
......@@ -132,19 +132,19 @@ Dict::~Dict() {
}
int Dict::incRef() {
lockDict();
dictLocker();
++ref;
return ref;
}
int Dict::decRef() {
lockDict();
dictLocker();
--ref;
return ref;
}
void Dict::add(char *key, Object *val) {
lockDict();
dictLocker();