[poppler] poppler/poppler: Gfx.cc, 1.8, 1.9 GfxFont.cc, 1.8,
1.9 GfxFont.h, 1.3, 1.4 GfxState.cc, 1.10,
1.11 TextOutputDev.cc, 1.17, 1.18
Kristian Høgsberg
krh at kemper.freedesktop.org
Mon May 1 21:38:41 PDT 2006
Update of /cvs/poppler/poppler/poppler
In directory kemper:/tmp/cvs-serv11071/poppler
Modified Files:
Gfx.cc GfxFont.cc GfxFont.h GfxState.cc TextOutputDev.cc
Log Message:
2006-05-02 Kristian Høgsberg <krh at redhat.com>
* glib/poppler-page.cc:
* poppler/Gfx.cc:
* poppler/GfxFont.cc:
* poppler/GfxFont.h:
* poppler/GfxState.cc:
* poppler/TextOutputDev.cc: Patch from Gary Coady to add reference
counting to GfxFont so we don't crash on text selection.
Index: Gfx.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/Gfx.cc,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- Gfx.cc 5 Feb 2006 15:46:10 -0000 1.8
+++ Gfx.cc 2 May 2006 04:38:39 -0000 1.9
@@ -2523,6 +2523,8 @@
args[1].getNum());
fflush(stdout);
}
+
+ font->incRefCnt();
state->setFont(font, args[1].getNum());
fontChanged = gTrue;
}
Index: GfxFont.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/GfxFont.cc,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- GfxFont.cc 5 Feb 2006 15:46:10 -0000 1.8
+++ GfxFont.cc 2 May 2006 04:38:39 -0000 1.9
@@ -148,6 +148,7 @@
family = NULL;
stretch = StretchNotDefined;
weight = WeightNotDefined;
+ refCnt = 1;
}
GfxFont::~GfxFont() {
@@ -167,6 +168,15 @@
}
}
+void GfxFont::incRefCnt() {
+ refCnt++;
+}
+
+void GfxFont::decRefCnt() {
+ if (--refCnt == 0)
+ delete this;
+}
+
void GfxFont::readFontDescriptor(XRef *xref, Dict *fontDict) {
Object obj1, obj2, obj3, obj4;
double t;
@@ -457,6 +467,7 @@
Object obj1, obj2, obj3;
int n, i, a, b, m;
+ refCnt = 1;
type = typeA;
ctu = NULL;
@@ -1108,6 +1119,7 @@
int c1, c2;
int excepsSize, i, j, k, n;
+ refCnt = 1;
ascent = 0.95;
descent = -0.35;
fontBBox[0] = fontBBox[1] = fontBBox[2] = fontBBox[3] = 0;
@@ -1620,7 +1632,7 @@
for (i = 0; i < numFonts; ++i) {
if (fonts[i]) {
- delete fonts[i];
+ fonts[i]->decRefCnt();
}
}
gfree(fonts);
Index: GfxFont.h
===================================================================
RCS file: /cvs/poppler/poppler/poppler/GfxFont.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- GfxFont.h 2 Feb 2006 22:50:01 -0000 1.3
+++ GfxFont.h 2 May 2006 04:38:39 -0000 1.4
@@ -115,6 +115,9 @@
GBool isOk() { return ok; }
+ void incRefCnt();
+ void decRefCnt();
+
// Get font tag.
GooString *getTag() { return tag; }
@@ -215,6 +218,7 @@
double missingWidth; // "default" width
double ascent; // max height above baseline
double descent; // max depth below baseline
+ int refCnt;
GBool ok;
};
Index: GfxState.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/GfxState.cc,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- GfxState.cc 18 Feb 2006 20:17:00 -0000 1.10
+++ GfxState.cc 2 May 2006 04:38:39 -0000 1.11
@@ -21,6 +21,7 @@
#include "Array.h"
#include "Page.h"
#include "GfxState.h"
+#include "GfxFont.h"
#include "UGooString.h"
//------------------------------------------------------------------------
@@ -3849,6 +3850,9 @@
if (saved) {
delete saved;
}
+ if (font) {
+ font->decRefCnt();
+ }
}
// Used for copy();
@@ -3870,6 +3874,9 @@
lineDash = (double *)gmallocn(lineDashLength, sizeof(double));
memcpy(lineDash, state->lineDash, lineDashLength * sizeof(double));
}
+ if (font)
+ font->incRefCnt();
+
saved = NULL;
}
Index: TextOutputDev.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/TextOutputDev.cc,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- TextOutputDev.cc 6 Jan 2006 10:05:58 -0000 1.17
+++ TextOutputDev.cc 2 May 2006 04:38:39 -0000 1.18
@@ -3359,6 +3359,7 @@
state->setFillColor(glyph_color);
out->updateFillColor(state);
+ word->font->gfxFont->incRefCnt();
state->setFont(word->font->gfxFont, word->fontSize);
out->updateFont(state);
More information about the poppler
mailing list