Commit a9b0c797 authored by Kristian Høgsberg's avatar Kristian Høgsberg

2006-05-02 Kristian Høgsberg <krh@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.
parent 57af0207
2006-05-02 Kristian Høgsberg <krh@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.
2006-05-01 Albert Astals Cid <aacid@kde.org>
* qt4/src/poppler-page.cc:
......
......@@ -273,7 +273,7 @@ poppler_page_copy_to_pixbuf(PopplerPage *page,
dst += pixbuf_n_channels;
}
}
delete pixel;
delete [] pixel;
}
#endif
......
......@@ -2523,6 +2523,8 @@ void Gfx::opSetFont(Object args[], int numArgs) {
args[1].getNum());
fflush(stdout);
}
font->incRefCnt();
state->setFont(font, args[1].getNum());
fontChanged = gTrue;
}
......
......@@ -148,6 +148,7 @@ GfxFont::GfxFont(char *tagA, Ref idA, GooString *nameA) {
family = NULL;
stretch = StretchNotDefined;
weight = WeightNotDefined;
refCnt = 1;
}
GfxFont::~GfxFont() {
......@@ -167,6 +168,15 @@ GfxFont::~GfxFont() {
}
}
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 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, char *tagA, Ref idA, GooString *nameA,
Object obj1, obj2, obj3;
int n, i, a, b, m;
refCnt = 1;
type = typeA;
ctu = NULL;
......@@ -1108,6 +1119,7 @@ GfxCIDFont::GfxCIDFont(XRef *xref, char *tagA, Ref idA, GooString *nameA,
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 @@ GfxFontDict::~GfxFontDict() {
for (i = 0; i < numFonts; ++i) {
if (fonts[i]) {
delete fonts[i];
fonts[i]->decRefCnt();
}
}
gfree(fonts);
......
......@@ -115,6 +115,9 @@ public:
GBool isOk() { return ok; }
void incRefCnt();
void decRefCnt();
// Get font tag.
GooString *getTag() { return tag; }
......@@ -215,6 +218,7 @@ protected:
double missingWidth; // "default" width
double ascent; // max height above baseline
double descent; // max depth below baseline
int refCnt;
GBool ok;
};
......
......@@ -21,6 +21,7 @@
#include "Array.h"
#include "Page.h"
#include "GfxState.h"
#include "GfxFont.h"
#include "UGooString.h"
//------------------------------------------------------------------------
......@@ -3849,6 +3850,9 @@ GfxState::~GfxState() {
if (saved) {
delete saved;
}
if (font) {
font->decRefCnt();
}
}
// Used for copy();
......@@ -3870,6 +3874,9 @@ GfxState::GfxState(GfxState *state) {
lineDash = (double *)gmallocn(lineDashLength, sizeof(double));
memcpy(lineDash, state->lineDash, lineDashLength * sizeof(double));
}
if (font)
font->incRefCnt();
saved = NULL;
}
......
......@@ -3359,6 +3359,7 @@ void TextSelectionPainter::visitWord (TextWord *word, int begin, int end,
state->setFillColor(glyph_color);
out->updateFillColor(state);
word->font->gfxFont->incRefCnt();
state->setFont(word->font->gfxFont, word->fontSize);
out->updateFont(state);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment