diff options
author | tsepez <tsepez@chromium.org> | 2016-11-09 13:28:26 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-11-09 13:28:26 -0800 |
commit | 335cf093231c984a23cb9ea113148ea1f19621ba (patch) | |
tree | e9c7803b0ce71269beb3d423549a2d6a0ac7784a /core/fpdfdoc | |
parent | 3ff4deea307c38462393e4f83dabe32949338168 (diff) | |
download | pdfium-335cf093231c984a23cb9ea113148ea1f19621ba.tar.xz |
Return unique_ptr from CPDF_Object::Clone().
Because that's what clone does. There are numerous
release() calls that will go away as more code is
converted.
Review-Url: https://codereview.chromium.org/2484033002
Diffstat (limited to 'core/fpdfdoc')
-rw-r--r-- | core/fpdfdoc/cpdf_formfield.cpp | 8 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_interform.cpp | 13 | ||||
-rw-r--r-- | core/fpdfdoc/cpvt_generateap.cpp | 6 |
3 files changed, 15 insertions, 12 deletions
diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp index 8170b7fcbf..4999f2d6b8 100644 --- a/core/fpdfdoc/cpdf_formfield.cpp +++ b/core/fpdfdoc/cpdf_formfield.cpp @@ -219,14 +219,14 @@ bool CPDF_FormField::ResetField(bool bNotify) { return false; if (pDV) { - CPDF_Object* pClone = pDV->Clone(); + std::unique_ptr<CPDF_Object> pClone = pDV->Clone(); if (!pClone) return false; - m_pDict->SetFor("V", pClone); + m_pDict->SetFor("V", pClone.release()); if (pRV) { - CPDF_Object* pCloneR = pDV->Clone(); - m_pDict->SetFor("RV", pCloneR); + std::unique_ptr<CPDF_Object> pCloneR = pDV->Clone(); + m_pDict->SetFor("RV", pCloneR.release()); } } else { m_pDict->RemoveFor("V"); diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp index f709c57961..2a02e890c3 100644 --- a/core/fpdfdoc/cpdf_interform.cpp +++ b/core/fpdfdoc/cpdf_interform.cpp @@ -1105,22 +1105,22 @@ CPDF_FormField* CPDF_InterForm::AddTerminalField(CPDF_Dictionary* pFieldDict) { if (pFieldDict->KeyExist("FT")) { CPDF_Object* pFTValue = pFieldDict->GetDirectObjectFor("FT"); if (pFTValue) - pParent->SetFor("FT", pFTValue->Clone()); + pParent->SetFor("FT", pFTValue->Clone().release()); } if (pFieldDict->KeyExist("Ff")) { CPDF_Object* pFfValue = pFieldDict->GetDirectObjectFor("Ff"); if (pFfValue) - pParent->SetFor("Ff", pFfValue->Clone()); + pParent->SetFor("Ff", pFfValue->Clone().release()); } } pField = new CPDF_FormField(this, pParent); CPDF_Object* pTObj = pDict->GetObjectFor("T"); if (ToReference(pTObj)) { - CPDF_Object* pClone = pTObj->CloneDirectObject(); + std::unique_ptr<CPDF_Object> pClone = pTObj->CloneDirectObject(); if (pClone) - pDict->SetFor("T", pClone); + pDict->SetFor("T", pClone.release()); else pDict->SetNameFor("T", ""); } @@ -1251,7 +1251,7 @@ CFDF_Document* CPDF_InterForm::ExportToFDF( } else { CPDF_Object* pV = FPDF_GetFieldAttr(pField->m_pDict, "V"); if (pV) - pFieldDict->SetFor("V", pV->CloneDirectObject()); + pFieldDict->SetFor("V", pV->CloneDirectObject().release()); } pFields->Add(pFieldDict); } @@ -1304,7 +1304,8 @@ void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict, if ((eType == CPDF_FormField::ListBox || eType == CPDF_FormField::ComboBox) && pFieldDict->KeyExist("Opt")) { pField->m_pDict->SetFor( - "Opt", pFieldDict->GetDirectObjectFor("Opt")->CloneDirectObject()); + "Opt", + pFieldDict->GetDirectObjectFor("Opt")->CloneDirectObject().release()); } if (bNotify && m_pFormNotify) { diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp index 66abde63a8..93ef9dc366 100644 --- a/core/fpdfdoc/cpvt_generateap.cpp +++ b/core/fpdfdoc/cpvt_generateap.cpp @@ -186,7 +186,8 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, pStreamResFontList->SetReferenceFor(sFontName, pDoc, pFontDict->GetObjNum()); } else { - pStreamDict->SetFor("Resources", pFormDict->GetDictFor("DR")->Clone()); + pStreamDict->SetFor("Resources", + pFormDict->GetDictFor("DR")->Clone().release()); pStreamResList = pStreamDict->GetDictFor("Resources"); } } @@ -437,7 +438,8 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, pStreamResFontList->SetReferenceFor(sFontName, pDoc, pFontDict->GetObjNum()); } else { - pStreamDict->SetFor("Resources", pFormDict->GetDictFor("DR")->Clone()); + pStreamDict->SetFor("Resources", + pFormDict->GetDictFor("DR")->Clone().release()); pStreamResList = pStreamDict->GetDictFor("Resources"); } } |