summaryrefslogtreecommitdiff
path: root/fpdfsdk/cpdfsdk_baannot.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-10-14 16:59:10 -0700
committerCommit bot <commit-bot@chromium.org>2016-10-14 16:59:10 -0700
commit3ba098595ae56b64eacc0c25ab76b89a4d78d920 (patch)
tree5c4db47295ea64cdf236c32ef7d5af5b8e7af232 /fpdfsdk/cpdfsdk_baannot.cpp
parent1d023881cd53485303c0fcc0b5878e700dc470fd (diff)
downloadpdfium-3ba098595ae56b64eacc0c25ab76b89a4d78d920.tar.xz
Update CPDF_IndirectObjectHolder APIs for unique objects.
Doing so highlights a few places where ownership is dubious. Add convenience functions to return an unowned reference to a newly-created indirect object. Review-Url: https://codereview.chromium.org/2419173002
Diffstat (limited to 'fpdfsdk/cpdfsdk_baannot.cpp')
-rw-r--r--fpdfsdk/cpdfsdk_baannot.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/fpdfsdk/cpdfsdk_baannot.cpp b/fpdfsdk/cpdfsdk_baannot.cpp
index 72468e180f..e704822e4d 100644
--- a/fpdfsdk/cpdfsdk_baannot.cpp
+++ b/fpdfsdk/cpdfsdk_baannot.cpp
@@ -316,10 +316,9 @@ void CPDFSDK_BAAnnot::WriteAppearance(const CFX_ByteString& sAPType,
}
if (!pStream) {
- pStream = new CPDF_Stream;
CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
- pParentDict->SetReferenceFor(sAPType, pDoc,
- pDoc->AddIndirectObject(pStream));
+ pStream = pDoc->AddIndirectStream();
+ pParentDict->SetReferenceFor(sAPType, pDoc, pStream);
}
CPDF_Dictionary* pStreamDict = pStream->GetDict();
@@ -354,8 +353,10 @@ void CPDFSDK_BAAnnot::SetAction(const CPDF_Action& action) {
CPDF_Dictionary* pDict = action.GetDict();
if (pDict != m_pAnnot->GetAnnotDict()->GetDictFor("A")) {
CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
- m_pAnnot->GetAnnotDict()->SetReferenceFor("A", pDoc,
- pDoc->AddIndirectObject(pDict));
+
+ // TODO(tsepez): check |pDict| ownership.
+ m_pAnnot->GetAnnotDict()->SetReferenceFor(
+ "A", pDoc, pDoc->AddIndirectObject(UniqueDictionary(pDict)));
}
}