From 1a4752317924d81460ddcbcd39e67fe678cf5b8c Mon Sep 17 00:00:00 2001 From: "vandebo@chromium.org" Date: Fri, 10 May 2013 18:29:43 +0000 Subject: [PATCH] [PDF] Only output the Dests dictionary if it isn't epmpty R=edisonn@google.com Review URL: https://codereview.chromium.org/15028012 git-svn-id: http://skia.googlecode.com/svn/trunk@9100 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/pdf/SkPDFDocument.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pdf/SkPDFDocument.cpp b/src/pdf/SkPDFDocument.cpp index 062263dce3..0633d30828 100644 --- a/src/pdf/SkPDFDocument.cpp +++ b/src/pdf/SkPDFDocument.cpp @@ -112,9 +112,7 @@ bool SkPDFDocument::emitPDF(SkWStream* stream) { fDocCatalog->insert("OutputIntent", intentArray.get()); */ - SkPDFDict* dests = SkNEW(SkPDFDict); // fPageResources owns reference - fCatalog->addObject(dests, true /* onFirstPage */); - fFirstPageResources->add(dests); + SkAutoTUnref dests(SkNEW(SkPDFDict)); bool firstPage = true; /* The references returned in newResources are transfered to @@ -151,7 +149,12 @@ bool SkPDFDocument::emitPDF(SkWStream* stream) { fPages[i]->appendDestinations(dests); } - fDocCatalog->insert("Dests", SkNEW_ARGS(SkPDFObjRef, (dests)))->unref(); + if (dests->size() > 0) { + SkPDFDict* raw_dests = dests.get(); + fFirstPageResources->add(dests.detach()); // Transfer ownership. + fCatalog->addObject(raw_dests, true /* onFirstPage */); + fDocCatalog->insert("Dests", SkNEW_ARGS(SkPDFObjRef, (raw_dests)))->unref(); + } // Build font subsetting info before proceeding. perform_font_subsetting(fCatalog.get(), fPages, &fSubstitutes);