[poppler] Branch 'better_object' - poppler/XRef.cc

2017-05-12 Thread Albert Astals Cid
 poppler/XRef.cc |1 +
 1 file changed, 1 insertion(+)

New commits:
commit b5ca57dbfecd9e680b3bd4b293b0eac400d24cfb
Author: Albert Astals Cid 
Date:   Sat May 13 01:05:43 2017 +0200

Fix memory leak in XRef::constructXRef

diff --git a/poppler/XRef.cc b/poppler/XRef.cc
index f32546ea..10526017 100644
--- a/poppler/XRef.cc
+++ b/poppler/XRef.cc
@@ -865,6 +865,7 @@ GBool XRef::constructXRef(GBool *wasReconstructed, GBool 
needCatalogDict) {
   bool oneCycle = true;
   int offset = 0;
 
+  resize(0); // free entries properly
   gfree(entries);
   capacity = 0;
   size = 0;
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] Branch 'better_object' - 2 commits - poppler/Rendition.h poppler/XRef.cc

2017-05-12 Thread Albert Astals Cid
 poppler/Rendition.h |1 +
 poppler/XRef.cc |2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

New commits:
commit b21c5f7741bb0af47c64c042a8586d922d26b47a
Author: Albert Astals Cid 
Date:   Sat May 13 00:13:43 2017 +0200

Use initNullAfterMalloc since this is after a greallocn

diff --git a/poppler/XRef.cc b/poppler/XRef.cc
index 2b50f83e..f32546ea 100644
--- a/poppler/XRef.cc
+++ b/poppler/XRef.cc
@@ -1322,7 +1322,7 @@ void XRef::add(int num, int gen, Goffset offs, GBool 
used) {
 for (int i = size; i < num + 1; ++i) {
   entries[i].offset = -1;
   entries[i].type = xrefEntryFree;
-  entries[i].obj.setToNull();
+  entries[i].obj.initNullAfterMalloc();
   entries[i].flags = 0;
   entries[i].gen = 0;
 }
commit e98ca09fafadbf7d37b838ed2f8953dc6a53a034
Author: Albert Astals Cid 
Date:   Sat May 13 00:01:05 2017 +0200

Forgot to add my (C) here

diff --git a/poppler/Rendition.h b/poppler/Rendition.h
index 3b26cea7..5a937f2c 100644
--- a/poppler/Rendition.h
+++ b/poppler/Rendition.h
@@ -5,6 +5,7 @@
 
//-
 // Hugo Mercier  (c) 2008
 // Carlos Garcia Campos  (c) 2010
+// Albert Astals Cid  (C) 2017
 //
 // 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
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


Re: [poppler] Branch 'better_object' - cpp/poppler-document.cpp cpp/poppler-page.cpp glib/poppler-action.cc glib/poppler-attachment.cc glib/poppler-document.cc glib/poppler-input-stream.cc glib/popple

2017-05-12 Thread Albert Astals Cid
El divendres, 12 de maig de 2017, a les 15:31:55 CEST, Carlos Garcia Campos va 
escriure:
> Albert Astals Cid  writes:
> 
> 
> This looks great, I have a couple of comments after a first glance.
> 
> >   if (!found)
> > 
> > -   annotObj.free ();
> > +   annotObj.setToNull ();
> 
> As I commented on IRC, I think
> 
> annotObj = Object(objNull);
> 
> is not less efficient, looks simpler and we don't need setToNull() at
> all.
> 
> > diff --git a/poppler/Annot.cc b/poppler/Annot.cc
> > index 73c2fe66..96a7e330 100644
> > --- a/poppler/Annot.cc
> > +++ b/poppler/Annot.cc
> > 
> > @@ -1228,12 +1188,13 @@ Annot::Annot(PDFDoc *docA, Dict *dict, Object
> > *obj) {> 
> >}
> >flags = flagUnknown;
> >type = typeUnknown;
> > 
> > -  annotObj.initDict (dict);
> > +  dict->incRef();
> > +  annotObj = Object(dict);
> > 
> >initialize (docA, dict);
> 
> I still find this pattern quite confusing. The problem is that Object()
> is taking the ownership of passing refcounted objects. That's not
> consistent with all other types where the value is copied. I think it
> should be Object() constructor the one doing the incRef() in case of
> dicts, arrays and streams.

You just complained exactly about the reverse thing (needing to do a decRef 
when passing a Dict to an Object) in the other email ;)

I've done a few changes making all the incRef/decRef private.

Now the the pattern is:
 * If you pass a Dict/Annot/Array to Object it will "take" it, that's most of 
the times correct because if you do that is because you just new'ed the Dict/
Annot/Array yourself
 * If what you want to do is incRef, you should be passing Objects and not raw 
Dict/Annot/Array

Does that work for you?

Cheers,
  Albert

> 
> >  }


___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] Branch 'better_object' - poppler/Catalog.cc poppler/Catalog.h poppler/Dict.h poppler/Page.cc poppler/Page.h poppler/PDFDoc.cc poppler/PDFDoc.h utils/pdfunite.cc

2017-05-12 Thread Albert Astals Cid
 poppler/Catalog.cc |   40 +++-
 poppler/Catalog.h  |2 +-
 poppler/Dict.h |9 +
 poppler/PDFDoc.cc  |   37 -
 poppler/PDFDoc.h   |7 +++
 poppler/Page.cc|   17 -
 poppler/Page.h |2 +-
 utils/pdfunite.cc  |   12 +---
 8 files changed, 50 insertions(+), 76 deletions(-)

New commits:
commit 47aa71cf39764135f3e3a39cbfb8efc50de1ac28
Author: Albert Astals Cid 
Date:   Fri May 12 23:38:26 2017 +0200

Make Dict incRef/decRef private

diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc
index 89dc..6c820c66 100644
--- a/poppler/Catalog.cc
+++ b/poppler/Catalog.cc
@@ -148,15 +148,7 @@ Catalog::~Catalog() {
 delete attrsList;
   }
   delete pagesRefList;
-  if (pagesList) {
-std::vector::iterator it;
-for (it = pagesList->begin() ; it != pagesList->end(); ++it ) {
-  if (!(*it)->decRef()) {
- delete *it;
-  }
-}
-delete pagesList;
-  }
+  delete pagesList;
   if (pages) {
 for (int i = 0; i < pagesSize; ++i) {
   if (pages[i]) {
@@ -238,8 +230,6 @@ Ref *Catalog::getPageRef(int i)
 
 GBool Catalog::cachePageTree(int page)
 {
-  Dict *pagesDict;
-
   if (pagesList == NULL) {
 
 Ref pagesRef;
@@ -264,10 +254,7 @@ GBool Catalog::cachePageTree(int page)
 Object obj = catDict.dictLookup("Pages");
 // This should really be isDict("Pages"), but I've seen at least one
 // PDF file where the /Type entry is missing.
-if (obj.isDict()) {
-  obj.getDict()->incRef();
-  pagesDict = obj.getDict();
-} else {
+if (!obj.isDict()) {
   error(errSyntaxError, -1, "Top-level pages object is wrong type 
({0:s})", obj.getTypeName());
   return gFalse;
 }
@@ -277,7 +264,6 @@ GBool Catalog::cachePageTree(int page)
 pageRefs = (Ref *)gmallocn_checkoverflow(pagesSize, sizeof(Ref));
 if (pages == NULL || pageRefs == NULL ) {
   error(errSyntaxError, -1, "Cannot allocate page cache");
-  pagesDict->decRef();
   pagesSize = 0;
   return gFalse;
 }
@@ -287,12 +273,12 @@ GBool Catalog::cachePageTree(int page)
   pageRefs[i].gen = -1;
 }
 
-pagesList = new std::vector();
-pagesList->push_back(pagesDict);
+attrsList = new std::vector();
+attrsList->push_back(new PageAttrs(NULL, obj.getDict()));
+pagesList = new std::vector();
+pagesList->push_back(std::move(obj));
 pagesRefList = new std::vector();
 pagesRefList->push_back(pagesRef);
-attrsList = new std::vector();
-attrsList->push_back(new PageAttrs(NULL, pagesDict));
 kidsIdxList = new std::vector();
 kidsIdxList->push_back(0);
 lastCachedPage = 0;
@@ -305,8 +291,8 @@ GBool Catalog::cachePageTree(int page)
 
 if (pagesList->empty()) return gFalse;
 
-pagesDict = pagesList->back();
-Object kids = pagesDict->lookup("Kids");
+Object pagesDict = pagesList->back().copy();
+Object kids = pagesDict.dictLookup("Kids");
 if (!kids.isArray()) {
   error(errSyntaxError, -1, "Kids object (page {0:d}) is wrong type 
({1:s})",
 lastCachedPage+1, kids.getTypeName());
@@ -315,9 +301,6 @@ GBool Catalog::cachePageTree(int page)
 
 int kidsIdx = kidsIdxList->back();
 if (kidsIdx >= kids.arrayGetLength()) {
-   if (!pagesList->back()->decRef()) {
- delete pagesList->back();
-   }
pagesList->pop_back();
pagesRefList->pop_back();
delete attrsList->back();
@@ -350,7 +333,7 @@ GBool Catalog::cachePageTree(int page)
 Object kid = kids.arrayGet(kidsIdx);
 if (kid.isDict("Page") || (kid.isDict() && 
!kid.getDict()->hasKey("Kids"))) {
   PageAttrs *attrs = new PageAttrs(attrsList->back(), kid.getDict());
-  Page *p = new Page(doc, lastCachedPage+1, kid.getDict(),
+  Page *p = new Page(doc, lastCachedPage+1, ,
  kidRef.getRef(), attrs, form);
   if (!p->isOk()) {
 error(errSyntaxError, -1, "Failed to create page (page {0:d})", 
lastCachedPage+1);
@@ -375,8 +358,7 @@ GBool Catalog::cachePageTree(int page)
 } else if (kid.isDict()) {
   attrsList->push_back(new PageAttrs(attrsList->back(), kid.getDict()));
   pagesRefList->push_back(kidRef.getRef());
-  kid.getDict()->incRef();
-  pagesList->push_back(kid.getDict());
+  pagesList->push_back(std::move(kid));
   kidsIdxList->push_back(0);
 } else {
   error(errSyntaxError, -1, "Kid object (page {0:d}) is wrong type 
({1:s})",
@@ -792,7 +774,7 @@ int Catalog::getNumPages()
Dict *pageDict = pagesDict.getDict();
if (pageRootRef.isRef()) {
  const Ref pageRef = pageRootRef.getRef();
- Page *p = new Page(doc, 1, pageDict, pageRef, new PageAttrs(NULL, 
pageDict), form);
+ Page *p = new Page(doc, 1, , pageRef, new PageAttrs(NULL, 
pageDict), form);
  if (p->isOk()) {
pages = (Page **)gmallocn(1, sizeof(Page *));

[poppler] Branch 'better_object' - poppler/Array.h poppler/PDFDoc.cc

2017-05-12 Thread Albert Astals Cid
 poppler/Array.h   |9 +
 poppler/PDFDoc.cc |   14 +++---
 2 files changed, 12 insertions(+), 11 deletions(-)

New commits:
commit 0d7aa8c8aa491e005f78b019eff78f400764a61c
Author: Albert Astals Cid 
Date:   Fri May 12 23:10:53 2017 +0200

Make Array incRef/decRef private

diff --git a/poppler/Array.h b/poppler/Array.h
index bc522a00..8043c830 100644
--- a/poppler/Array.h
+++ b/poppler/Array.h
@@ -49,10 +49,6 @@ public:
   // Destructor.
   ~Array();
 
-  // Reference counting.
-  int incRef();
-  int decRef();
-
   // Get number of elements.
   int getLength() { return length; }
 
@@ -72,6 +68,11 @@ public:
   GBool getString(int i, GooString *string);
 
 private:
+  friend class Object; // for incRef/decRef
+
+  // Reference counting.
+  int incRef();
+  int decRef();
 
   XRef *xref;  // the xref table for this PDF file
   Object *elems;   // array of elements
diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc
index 5f640790..16981b93 100644
--- a/poppler/PDFDoc.cc
+++ b/poppler/PDFDoc.cc
@@ -1567,20 +1567,20 @@ void PDFDoc::replacePageDict(int pageNo, int rotate,
   mediaBoxArray->add(Object(mediaBox->y1));
   mediaBoxArray->add(Object(mediaBox->x2));
   mediaBoxArray->add(Object(mediaBox->y2));
-  pageDict->add(copyString("MediaBox"), Object(mediaBoxArray));
+  Object mediaBoxObject(mediaBoxArray);
+  Object trimBoxObject = mediaBoxObject.copy();
+  pageDict->add(copyString("MediaBox"), std::move(mediaBoxObject));
   if (cropBox != NULL) {
 Array *cropBoxArray = new Array(getXRef());
 cropBoxArray->add(Object(cropBox->x1));
 cropBoxArray->add(Object(cropBox->y1));
 cropBoxArray->add(Object(cropBox->x2));
 cropBoxArray->add(Object(cropBox->y2));
-pageDict->add(copyString("CropBox"), Object(cropBoxArray));
-cropBoxArray->incRef();
-pageDict->add(copyString("TrimBox"), Object(cropBoxArray));
-  } else {
-mediaBoxArray->incRef();
-pageDict->add(copyString("TrimBox"), Object(mediaBoxArray));
+Object cropBoxObject(cropBoxArray);
+trimBoxObject = cropBoxObject.copy();
+pageDict->add(copyString("CropBox"), std::move(cropBoxObject));
   }
+  pageDict->add(copyString("TrimBox"), std::move(trimBoxObject));
   pageDict->add(copyString("Rotate"), Object(rotate));
   getXRef()->setModifiedObject(, *refPage);
 }
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] Branch 'better_object' - 2 commits - glib/poppler-action.cc glib/poppler-attachment.cc glib/poppler-media.cc poppler/Annot.cc poppler/FileSpec.h poppler/Rendition.cc poppler/Rendition.h popp

2017-05-12 Thread Albert Astals Cid
 glib/poppler-action.cc |2 -
 glib/poppler-attachment.cc |   15 +++-
 glib/poppler-media.cc  |   19 ++--
 poppler/Annot.cc   |5 
 poppler/FileSpec.h |1 
 poppler/Rendition.cc   |   53 ++---
 poppler/Rendition.h|6 +++--
 poppler/Stream.cc  |1 
 poppler/Stream.h   |   18 +--
 9 files changed, 51 insertions(+), 69 deletions(-)

New commits:
commit b1f4e35fa2da8909dee07529ce1dd9445639793b
Author: Albert Astals Cid 
Date:   Fri May 12 23:03:28 2017 +0200

Make Stream incRef/decRef private

Object handles it for us

Also remove incRef/decRef from OutStream

diff --git a/glib/poppler-action.cc b/glib/poppler-action.cc
index e74d822d..ad8ed18d 100644
--- a/glib/poppler-action.cc
+++ b/glib/poppler-action.cc
@@ -476,7 +476,7 @@ find_annot_movie_for_action (PopplerDocument *document,
   if (annotObj.isDict ()) {
 Object tmp;
 
-annot = new AnnotMovie (document->doc, annotObj.getDict(), );
+annot = new AnnotMovie (document->doc, , );
 if (!annot->isOk ()) {
   delete annot;
   annot = NULL;
diff --git a/glib/poppler-attachment.cc b/glib/poppler-attachment.cc
index 55936e78..5d84595a 100644
--- a/glib/poppler-attachment.cc
+++ b/glib/poppler-attachment.cc
@@ -35,7 +35,7 @@
 typedef struct _PopplerAttachmentPrivate PopplerAttachmentPrivate;
 struct _PopplerAttachmentPrivate
 {
-  Object *obj_stream;
+  Object obj_stream;
 };
 
 #define POPPLER_ATTACHMENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE 
((obj), POPPLER_TYPE_ATTACHMENT, PopplerAttachmentPrivate))
@@ -64,12 +64,7 @@ poppler_attachment_dispose (GObject *obj)
   PopplerAttachmentPrivate *priv;
 
   priv = POPPLER_ATTACHMENT_GET_PRIVATE (obj);
-
-  if (priv->obj_stream)
-{
-  delete priv->obj_stream;
-  priv->obj_stream = NULL;
-}
+  priv->obj_stream = Object();
 
   G_OBJECT_CLASS (poppler_attachment_parent_class)->dispose (obj);
 }
@@ -126,9 +121,7 @@ _poppler_attachment_new (FileSpec *emb_file)
   if (embFile->checksum () && embFile->checksum ()->getLength () > 0)
 attachment->checksum = g_string_new_len (embFile->checksum ()->getCString 
(),
  embFile->checksum ()->getLength 
());
-  priv->obj_stream = new Object(embFile->stream());
-  // Copy the stream
-  embFile->stream()->incRef();
+  priv->obj_stream = embFile->streamObject()->copy();
 
   return attachment;
 }
@@ -241,7 +234,7 @@ poppler_attachment_save_to_callback (PopplerAttachment  
*attachment,
 
   g_return_val_if_fail (POPPLER_IS_ATTACHMENT (attachment), FALSE);
 
-  stream = POPPLER_ATTACHMENT_GET_PRIVATE 
(attachment)->obj_stream->getStream();
+  stream = POPPLER_ATTACHMENT_GET_PRIVATE (attachment)->obj_stream.getStream();
   stream->reset();
 
   do
diff --git a/glib/poppler-media.cc b/glib/poppler-media.cc
index 57123719..8634af43 100644
--- a/glib/poppler-media.cc
+++ b/glib/poppler-media.cc
@@ -40,7 +40,7 @@ struct _PopplerMedia
   gchar  *filename;
 
   gchar  *mime_type;
-  Stream *stream;
+  Object stream;
 };
 
 struct _PopplerMediaClass
@@ -65,10 +65,7 @@ poppler_media_finalize (GObject *object)
 media->mime_type = NULL;
   }
 
-  if (media->stream) {
-media->stream->decRef();
-media->stream = NULL;
-  }
+  media->stream = Object();
 
   G_OBJECT_CLASS (poppler_media_parent_class)->finalize (object);
 }
@@ -98,7 +95,7 @@ _poppler_media_new (MediaRendition *poppler_media)
   if (poppler_media->getIsEmbedded()) {
 GooString* mime_type;
 
-media->stream = poppler_media->getEmbbededStream();
+media->stream = poppler_media->getEmbbededStreamObject()->copy();
 mime_type = poppler_media->getContentType();
 if (mime_type)
   media->mime_type = g_strdup (mime_type->getCString());
@@ -124,7 +121,7 @@ const gchar *
 poppler_media_get_filename (PopplerMedia *poppler_media)
 {
   g_return_val_if_fail (POPPLER_IS_MEDIA (poppler_media), NULL);
-  g_return_val_if_fail (poppler_media->stream == NULL, NULL);
+  g_return_val_if_fail (!poppler_media->stream.isStream(), NULL);
 
   return poppler_media->filename;
 }
@@ -147,7 +144,7 @@ poppler_media_is_embedded (PopplerMedia *poppler_media)
 {
   g_return_val_if_fail (POPPLER_IS_MEDIA (poppler_media), FALSE);
 
-  return poppler_media->stream != NULL;
+  return poppler_media->stream.isStream();
 }
 
 /**
@@ -215,7 +212,7 @@ poppler_media_save (PopplerMedia *poppler_media,
   FILE *f;
 
   g_return_val_if_fail (POPPLER_IS_MEDIA (poppler_media), FALSE);
-  g_return_val_if_fail (poppler_media->stream != NULL, FALSE);
+  g_return_val_if_fail (poppler_media->stream.isStream(), FALSE);
 
   f = g_fopen (filename, "wb");
 
@@ -281,9 +278,9 @@ poppler_media_save_to_callback (PopplerMedia
*poppler_media,
   gboolean eof_reached = FALSE;
 
   g_return_val_if_fail (POPPLER_IS_MEDIA (poppler_media), FALSE);
-  g_return_val_if_fail 

Re: [poppler] Branch 'better_object' - poppler/SplashOutputDev.cc

2017-05-12 Thread Jason Crain
On Fri, May 12, 2017 at 03:39:27PM -0500, Joan Ronck wrote:
> REMOVE MY NAME FROM THIS MAILING LIST!!!

Please stop sending this to the mailing list.  It's not going to help.
Use the link in the email footer to unsubscribe yourself.

> https://lists.freedesktop.org/mailman/listinfo/poppler
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


Re: [poppler] Branch 'better_object' - poppler/SplashOutputDev.cc

2017-05-12 Thread Joan Ronck
REMOVE MY NAME FROM THIS MAILING LIST!!!

Sent from my iPhone

On May 12, 2017, at 3:25 PM, Albert Astals Cid  
wrote:

poppler/SplashOutputDev.cc |4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 0321bca7a3f6f5bd8b8f3e6ad13f4441e53c909b
Author: Albert Astals Cid 
Date:   Fri May 12 22:25:36 2017 +0200

   SplashOutputDev::doUpdateFont - Fix crash on broken file

diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc
index 1158ccc2..4bdc79c2 100644
--- a/poppler/SplashOutputDev.cc
+++ b/poppler/SplashOutputDev.cc
@@ -2075,8 +2075,10 @@ reload:
  delete id;
  delete fontLoc;
  fontLoc = NULL;
-  if (fontsrc && !fontsrc->isFile)
+  if (fontsrc && !fontsrc->isFile) {
  fontsrc->unref();
+  fontsrc = nullptr;
+  }

  id = new SplashOutFontFileID(gfxFont->getID());
  if ((fontFile = fontEngine->getFontFile(id))) {
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler

___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] Branch 'better_object' - poppler/Annot.cc poppler/Annot.h poppler/Form.cc

2017-05-12 Thread Albert Astals Cid
 poppler/Annot.cc |  198 +++
 poppler/Annot.h  |   46 ++--
 poppler/Form.cc  |2 
 3 files changed, 122 insertions(+), 124 deletions(-)

New commits:
commit a7f2baa21a09454cb393dce806896e62e548f63e
Author: Albert Astals Cid 
Date:   Fri May 12 22:38:41 2017 +0200

Pass the Object around instead of the Dict

Saves an awkard incRef call

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 96a7e330..5d52b51a 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -1168,17 +1168,16 @@ Annot::Annot(PDFDoc *docA, PDFRectangle *rectA) {
   initialize (docA, annotObj.getDict());
 }
 
-Annot::Annot(PDFDoc *docA, Dict *dict) {
+Annot::Annot(PDFDoc *docA, Object *dictObject) {
   refCnt = 1;
   hasRef = false;
   flags = flagUnknown;
   type = typeUnknown;
-  dict->incRef();
-  annotObj = Object(dict);
-  initialize (docA, dict);
+  annotObj = dictObject->copy();
+  initialize (docA, dictObject->getDict());
 }
 
-Annot::Annot(PDFDoc *docA, Dict *dict, Object *obj) {
+Annot::Annot(PDFDoc *docA, Object *dictObject, Object *obj) {
   refCnt = 1;
   if (obj->isRef()) {
 hasRef = gTrue;
@@ -1188,9 +1187,8 @@ Annot::Annot(PDFDoc *docA, Dict *dict, Object *obj) {
   }
   flags = flagUnknown;
   type = typeUnknown;
-  dict->incRef();
-  annotObj = Object(dict);
-  initialize (docA, dict);
+  annotObj = dictObject->copy();
+  initialize (docA, dictObject->getDict());
 }
 
 void Annot::initialize(PDFDoc *docA, Dict *dict) {
@@ -1847,10 +1845,10 @@ AnnotPopup::AnnotPopup(PDFDoc *docA, PDFRectangle 
*rect) :
   initialize (docA, annotObj.getDict());
 }
 
-AnnotPopup::AnnotPopup(PDFDoc *docA, Dict *dict, Object *obj) :
-Annot(docA, dict, obj) {
+AnnotPopup::AnnotPopup(PDFDoc *docA, Object *dictObject, Object *obj) :
+Annot(docA, dictObject, obj) {
   type = typePopup;
-  initialize(docA, dict);
+  initialize(docA, dictObject->getDict());
 }
 
 AnnotPopup::~AnnotPopup() {
@@ -1892,9 +1890,9 @@ AnnotMarkup::AnnotMarkup(PDFDoc *docA, PDFRectangle 
*rect) :
   initialize(docA, annotObj.getDict(), );
 }
 
-AnnotMarkup::AnnotMarkup(PDFDoc *docA, Dict *dict, Object *obj) :
-Annot(docA, dict, obj) {
-  initialize(docA, dict, obj);
+AnnotMarkup::AnnotMarkup(PDFDoc *docA, Object *dictObject, Object *obj) :
+Annot(docA, dictObject, obj) {
+  initialize(docA, dictObject->getDict(), obj);
 }
 
 AnnotMarkup::~AnnotMarkup() {
@@ -1924,7 +1922,7 @@ void AnnotMarkup::initialize(PDFDoc *docA, Dict *dict, 
Object *obj) {
   obj1 = dict->lookup("Popup");
   obj2 = dict->lookupNF("Popup");
   if (obj1.isDict() && obj2.isRef()) {
-popup = new AnnotPopup(docA, obj1.getDict(), );
+popup = new AnnotPopup(docA, , );
   } else {
 popup = NULL;
   }
@@ -2073,12 +2071,12 @@ AnnotText::AnnotText(PDFDoc *docA, PDFRectangle *rect) :
   initialize (docA, annotObj.getDict());
 }
 
-AnnotText::AnnotText(PDFDoc *docA, Dict *dict, Object *obj) :
-AnnotMarkup(docA, dict, obj) {
+AnnotText::AnnotText(PDFDoc *docA, Object *dictObject, Object *obj) :
+AnnotMarkup(docA, dictObject, obj) {
 
   type = typeText;
   flags |= flagNoZoom | flagNoRotate;
-  initialize (docA, dict);
+  initialize (docA, dictObject->getDict());
 }
 
 AnnotText::~AnnotText() {
@@ -2512,11 +2510,11 @@ AnnotLink::AnnotLink(PDFDoc *docA, PDFRectangle *rect) :
   initialize (docA, annotObj.getDict());
 }
 
-AnnotLink::AnnotLink(PDFDoc *docA, Dict *dict, Object *obj) :
-Annot(docA, dict, obj) {
+AnnotLink::AnnotLink(PDFDoc *docA, Object *dictObject, Object *obj) :
+Annot(docA, dictObject, obj) {
 
   type = typeLink;
-  initialize (docA, dict);
+  initialize (docA, dictObject->getDict());
 }
 
 AnnotLink::~AnnotLink() {
@@ -2615,10 +2613,10 @@ AnnotFreeText::AnnotFreeText(PDFDoc *docA, PDFRectangle 
*rect, GooString *da) :
   initialize (docA, annotObj.getDict());
 }
 
-AnnotFreeText::AnnotFreeText(PDFDoc *docA, Dict *dict, Object *obj) :
-AnnotMarkup(docA, dict, obj) {
+AnnotFreeText::AnnotFreeText(PDFDoc *docA, Object *dictObject, Object *obj) :
+AnnotMarkup(docA, dictObject, obj) {
   type = typeFreeText;
-  initialize(docA, dict);
+  initialize(docA, dictObject->getDict());
 }
 
 AnnotFreeText::~AnnotFreeText() {
@@ -3023,10 +3021,10 @@ AnnotLine::AnnotLine(PDFDoc *docA, PDFRectangle *rect) :
   initialize (docA, annotObj.getDict());
 }
 
-AnnotLine::AnnotLine(PDFDoc *docA, Dict *dict, Object *obj) :
-AnnotMarkup(docA, dict, obj) {
+AnnotLine::AnnotLine(PDFDoc *docA, Object *dictObject, Object *obj) :
+AnnotMarkup(docA, dictObject, obj) {
   type = typeLine;
-  initialize(docA, dict);
+  initialize(docA, dictObject->getDict());
 }
 
 AnnotLine::~AnnotLine() {
@@ -3490,11 +3488,11 @@ AnnotTextMarkup::AnnotTextMarkup(PDFDoc *docA, 
PDFRectangle *rect, AnnotSubtype
   initialize(docA, annotObj.getDict());
 }
 
-AnnotTextMarkup::AnnotTextMarkup(PDFDoc *docA, Dict *dict, Object *obj) :
-  AnnotMarkup(docA, dict, obj) {

[poppler] Branch 'better_object' - poppler/SplashOutputDev.cc

2017-05-12 Thread Albert Astals Cid
 poppler/SplashOutputDev.cc |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 0321bca7a3f6f5bd8b8f3e6ad13f4441e53c909b
Author: Albert Astals Cid 
Date:   Fri May 12 22:25:36 2017 +0200

SplashOutputDev::doUpdateFont - Fix crash on broken file

diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc
index 1158ccc2..4bdc79c2 100644
--- a/poppler/SplashOutputDev.cc
+++ b/poppler/SplashOutputDev.cc
@@ -2075,8 +2075,10 @@ reload:
   delete id;
   delete fontLoc;
   fontLoc = NULL;
-  if (fontsrc && !fontsrc->isFile)
+  if (fontsrc && !fontsrc->isFile) {
   fontsrc->unref();
+  fontsrc = nullptr;
+  }
 
   id = new SplashOutFontFileID(gfxFont->getID());
   if ((fontFile = fontEngine->getFontFile(id))) {
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


Re: [poppler] Branch 'better_object' - cpp/poppler-document.cpp cpp/poppler-page.cpp glib/poppler-action.cc glib/poppler-attachment.cc glib/poppler-document.cc glib/poppler-input-stream.cc glib/popple

2017-05-12 Thread Carlos Garcia Campos
Albert Astals Cid  writes:


This looks great, I have a couple of comments after a first glance.


> if (!found)
> - annotObj.free ();
> + annotObj.setToNull ();

As I commented on IRC, I think

annotObj = Object(objNull);

is not less efficient, looks simpler and we don't need setToNull() at
all.


> diff --git a/poppler/Annot.cc b/poppler/Annot.cc
> index 73c2fe66..96a7e330 100644
> --- a/poppler/Annot.cc
> +++ b/poppler/Annot.cc

> @@ -1228,12 +1188,13 @@ Annot::Annot(PDFDoc *docA, Dict *dict, Object *obj) {
>}
>flags = flagUnknown;
>type = typeUnknown;
> -  annotObj.initDict (dict);
> +  dict->incRef();
> +  annotObj = Object(dict);
>initialize (docA, dict);

I still find this pattern quite confusing. The problem is that Object()
is taking the ownership of passing refcounted objects. That's not
consistent with all other types where the value is copied. I think it
should be Object() constructor the one doing the incRef() in case of
dicts, arrays and streams.

>  }
>  

-- 
Carlos Garcia Campos
PGP key: http://pgp.mit.edu:11371/pks/lookup?op=get=0x523E6462


signature.asc
Description: PGP signature
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler