X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpdf%2Fpdf.cc;h=f06949ea5ea6794352495aba59ffad126f1b7f60;hb=072be5204983fd801b1d573f5a8efc6e0ae2bc5a;hp=4bcf9b9f017ee54f54a2312273cfc1cc07ed6851;hpb=cba26480d2932910cb2593c6e128c166c109c9e9;p=swftools.git diff --git a/lib/pdf/pdf.cc b/lib/pdf/pdf.cc index 4bcf9b9..f06949e 100644 --- a/lib/pdf/pdf.cc +++ b/lib/pdf/pdf.cc @@ -115,6 +115,8 @@ void pdfpage_rendersection(gfxpage_t*page, gfxdevice_t*output, gfxcoord_t x, gfx pi->outputDev->setDevice(0); } +static int globalparams_count=0; + void pdf_doc_destroy(gfxdocument_t*gfx) { pdf_doc_internal_t*i= (pdf_doc_internal_t*)gfx->internal; @@ -135,6 +137,13 @@ void pdf_doc_destroy(gfxdocument_t*gfx) free(global_page_range); global_page_range = 0; } + + globalparams_count--; + if(!globalparams_count) { + delete globalParams; + globalParams = 0; + globalparams_count = 0; + } } void pdf_doc_set_parameter(gfxdocument_t*gfx, const char*name, const char*value) @@ -300,6 +309,11 @@ static void pdf_set_parameter(const char*name, const char*value) static gfxdocument_t*pdf_open(const char*filename) { + if(!globalParams) { + globalParams = new GFXGlobalParams(); + globalparams_count++; + } + gfxdocument_t*pdf_doc = (gfxdocument_t*)malloc(sizeof(gfxdocument_t)); memset(pdf_doc, 0, sizeof(gfxdocument_t)); pdf_doc_internal_t*i= (pdf_doc_internal_t*)malloc(sizeof(pdf_doc_internal_t)); @@ -318,10 +332,6 @@ static gfxdocument_t*pdf_open(const char*filename) GString *fileName = new GString(filename); GString *userPW; - // read config file - if(!globalParams) - globalParams = new GlobalParams(""); - // open PDF file if (userPassword && userPassword[0]) { userPW = new GString(userPassword);