[poppler] poppler/Catalog.cc poppler/Page.cc poppler/Page.h poppler/PDFDoc.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Nov 16 22:14:42 UTC 2018


 poppler/Catalog.cc |    4 ++--
 poppler/PDFDoc.cc  |    2 +-
 poppler/Page.cc    |   16 ++++++++--------
 poppler/Page.h     |    2 +-
 4 files changed, 12 insertions(+), 12 deletions(-)

New commits:
commit 647a9813c41d936feea063f42060535464314ccc
Author: Albert Astals Cid <aacid at kde.org>
Date:   Fri Nov 16 23:14:13 2018 +0100

    Save Object::copy on Page construction

diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc
index a842dbfd..2d63a7d2 100644
--- a/poppler/Catalog.cc
+++ b/poppler/Catalog.cc
@@ -293,7 +293,7 @@ bool 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());
-      auto p = std::make_unique<Page>(doc, pages.size()+1, &kid,
+      auto p = std::make_unique<Page>(doc, pages.size()+1, std::move(kid),
 				      kidRef.getRef(), attrs, form);
       if (!p->isOk()) {
 	error(errSyntaxError, -1, "Failed to create page (page {0:uld})", pages.size()+1);
@@ -739,7 +739,7 @@ int Catalog::getNumPages()
 	Dict *pageDict = pagesDict.getDict();
 	if (pageRootRef.isRef()) {
 	  const Ref pageRef = pageRootRef.getRef();
-	  auto p = std::make_unique<Page>(doc, 1, &pagesDict, pageRef, new PageAttrs(nullptr, pageDict), form);
+	  auto p = std::make_unique<Page>(doc, 1, std::move(pagesDict), pageRef, new PageAttrs(nullptr, pageDict), form);
 	  if (p->isOk()) {
 	    pages.emplace_back(std::move(p), pageRef);
 
diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc
index 4f094905..b7fbae78 100644
--- a/poppler/PDFDoc.cc
+++ b/poppler/PDFDoc.cc
@@ -2099,7 +2099,7 @@ Page *PDFDoc::parsePage(int page)
   }
   Dict *pageDict = obj.getDict();
 
-  return new Page(this, page, &obj, pageRef,
+  return new Page(this, page, std::move(obj), pageRef,
                new PageAttrs(nullptr, pageDict), catalog->getForm());
 }
 
diff --git a/poppler/Page.cc b/poppler/Page.cc
index 15f751bc..6d6d8642 100644
--- a/poppler/Page.cc
+++ b/poppler/Page.cc
@@ -242,7 +242,7 @@ bool PageAttrs::readBox(Dict *dict, const char *key, PDFRectangle *box) {
 
 #define pageLocker()   std::unique_lock<std::recursive_mutex> locker(mutex)
 
-Page::Page(PDFDoc *docA, int numA, Object *pageDict, Ref pageRefA, PageAttrs *attrsA, Form *form) {
+Page::Page(PDFDoc *docA, int numA, Object &&pageDict, Ref pageRefA, PageAttrs *attrsA, Form *form) {
   ok = true;
   doc = docA;
   xref = doc->getXRef();
@@ -250,7 +250,7 @@ Page::Page(PDFDoc *docA, int numA, Object *pageDict, Ref pageRefA, PageAttrs *at
   duration = -1;
   annots = nullptr;
 
-  pageObj = pageDict->copy();
+  pageObj = std::move(pageDict);
   pageRef = pageRefA;
 
   // get attributes
@@ -258,7 +258,7 @@ Page::Page(PDFDoc *docA, int numA, Object *pageDict, Ref pageRefA, PageAttrs *at
   attrs->clipBoxes();
 
   // transtion
-  trans = pageDict->dictLookupNF("Trans");
+  trans = pageObj.dictLookupNF("Trans");
   if (!(trans.isRef() || trans.isDict() || trans.isNull())) {
     error(errSyntaxError, -1, "Page transition object (page {0:d}) is wrong type ({1:s})",
 	  num, trans.getTypeName());
@@ -266,7 +266,7 @@ Page::Page(PDFDoc *docA, int numA, Object *pageDict, Ref pageRefA, PageAttrs *at
   }
 
   // duration
-  Object tmp = pageDict->dictLookupNF("Dur");
+  Object tmp = pageObj.dictLookupNF("Dur");
   if (!(tmp.isNum() || tmp.isNull())) {
     error(errSyntaxError, -1, "Page duration object (page {0:d}) is wrong type ({1:s})",
 	  num, tmp.getTypeName());
@@ -275,7 +275,7 @@ Page::Page(PDFDoc *docA, int numA, Object *pageDict, Ref pageRefA, PageAttrs *at
   }
 
   // annotations
-  annotsObj = pageDict->dictLookupNF("Annots");
+  annotsObj = pageObj.dictLookupNF("Annots");
   if (!(annotsObj.isRef() || annotsObj.isArray() || annotsObj.isNull())) {
     error(errSyntaxError, -1, "Page annotations object (page {0:d}) is wrong type ({1:s})",
 	  num, annotsObj.getTypeName());
@@ -283,7 +283,7 @@ Page::Page(PDFDoc *docA, int numA, Object *pageDict, Ref pageRefA, PageAttrs *at
   }
 
   // contents
-  contents = pageDict->dictLookupNF("Contents");
+  contents = pageObj.dictLookupNF("Contents");
   if (!(contents.isRef() || contents.isArray() ||
 	contents.isNull())) {
     error(errSyntaxError, -1, "Page contents object (page {0:d}) is wrong type ({1:s})",
@@ -292,7 +292,7 @@ Page::Page(PDFDoc *docA, int numA, Object *pageDict, Ref pageRefA, PageAttrs *at
   }
 
   // thumb
-  thumb = pageDict->dictLookupNF("Thumb");
+  thumb = pageObj.dictLookupNF("Thumb");
   if (!(thumb.isStream() || thumb.isNull() || thumb.isRef())) {
       error(errSyntaxError, -1, "Page thumb object (page {0:d}) is wrong type ({1:s})",
             num, thumb.getTypeName());
@@ -300,7 +300,7 @@ Page::Page(PDFDoc *docA, int numA, Object *pageDict, Ref pageRefA, PageAttrs *at
   }
 
   // actions
-  actions = pageDict->dictLookupNF("AA");
+  actions = pageObj.dictLookupNF("AA");
   if (!(actions.isDict() || actions.isNull())) {
       error(errSyntaxError, -1, "Page additional action object (page {0:d}) is wrong type ({1:s})",
             num, actions.getTypeName());
diff --git a/poppler/Page.h b/poppler/Page.h
index 37b59455..01f056f9 100644
--- a/poppler/Page.h
+++ b/poppler/Page.h
@@ -141,7 +141,7 @@ class Page {
 public:
 
   // Constructor.
-  Page(PDFDoc *docA, int numA, Object *pageDict, Ref pageRefA, PageAttrs *attrsA, Form *form);
+  Page(PDFDoc *docA, int numA, Object &&pageDict, Ref pageRefA, PageAttrs *attrsA, Form *form);
 
   // Destructor.
   ~Page();


More information about the poppler mailing list