From 5a6c1398d0e559fb6a048cb0dca46ba9f9309a77 Mon Sep 17 00:00:00 2001 From: weili Date: Mon, 11 Jul 2016 14:43:40 -0700 Subject: Use smart pointers for class owned member variables Replace raw member variables to smart pointer type to better maintain the ownership and to ease the management. BUG=pdfium:518 Review-Url: https://codereview.chromium.org/2136683002 --- core/fpdfdoc/doc_annot.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'core/fpdfdoc/doc_annot.cpp') diff --git a/core/fpdfdoc/doc_annot.cpp b/core/fpdfdoc/doc_annot.cpp index 9b2f9e505f..fe17e9c811 100644 --- a/core/fpdfdoc/doc_annot.cpp +++ b/core/fpdfdoc/doc_annot.cpp @@ -41,7 +41,8 @@ CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) pAnnots->RemoveAt(i + 1); pDict = pAnnots->GetDictAt(i); } - m_AnnotList.push_back(new CPDF_Annot(pDict, this)); + m_AnnotList.push_back( + std::unique_ptr(new CPDF_Annot(pDict, this))); if (bRegenerateAP && pDict->GetStringBy("Subtype") == "Widget" && CPDF_InterForm::UpdatingAPEnabled()) { FPDF_GenerateAP(m_pDocument, pDict); @@ -49,10 +50,7 @@ CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) } } -CPDF_AnnotList::~CPDF_AnnotList() { - for (CPDF_Annot* annot : m_AnnotList) - delete annot; -} +CPDF_AnnotList::~CPDF_AnnotList() {} void CPDF_AnnotList::DisplayPass(CPDF_Page* pPage, CFX_RenderDevice* pDevice, @@ -62,7 +60,7 @@ void CPDF_AnnotList::DisplayPass(CPDF_Page* pPage, FX_BOOL bWidgetPass, CPDF_RenderOptions* pOptions, FX_RECT* clip_rect) { - for (CPDF_Annot* pAnnot : m_AnnotList) { + for (const auto& pAnnot : m_AnnotList) { bool bWidget = pAnnot->GetSubType() == "Widget"; if ((bWidgetPass && !bWidget) || (!bWidgetPass && bWidget)) continue; -- cgit v1.2.3