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

Albert Astals Cid aacid at kemper.freedesktop.org
Fri May 12 21:11:09 UTC 2017


 poppler/Array.h   |    9 +++++----
 poppler/PDFDoc.cc |   14 +++++++-------
 2 files changed, 12 insertions(+), 11 deletions(-)

New commits:
commit 0d7aa8c8aa491e005f78b019eff78f400764a61c
Author: Albert Astals Cid <aacid at kde.org>
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(&page, *refPage);
 }


More information about the poppler mailing list