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 --- fpdfsdk/fsdk_mgr.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'fpdfsdk') diff --git a/fpdfsdk/fsdk_mgr.cpp b/fpdfsdk/fsdk_mgr.cpp index 6500e302ec..32cc39622b 100644 --- a/fpdfsdk/fsdk_mgr.cpp +++ b/fpdfsdk/fsdk_mgr.cpp @@ -564,23 +564,23 @@ void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, const CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY) { - for (const CPDF_Annot* pAnnot : m_pAnnotList->All()) { + for (const auto& pAnnot : m_pAnnotList->All()) { CFX_FloatRect annotRect; pAnnot->GetRect(annotRect); if (annotRect.Contains(pageX, pageY)) - return pAnnot; + return pAnnot.get(); } return nullptr; } const CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY) { - for (const CPDF_Annot* pAnnot : m_pAnnotList->All()) { + for (const auto& pAnnot : m_pAnnotList->All()) { if (pAnnot->GetSubType() == "Widget") { CFX_FloatRect annotRect; pAnnot->GetRect(annotRect); if (annotRect.Contains(pageX, pageY)) - return pAnnot; + return pAnnot.get(); } } return nullptr; @@ -1024,7 +1024,8 @@ bool CPDFSDK_PageView::IsValidAnnot(const CPDF_Annot* p) const { return false; const auto& annots = m_pAnnotList->All(); - return pdfium::ContainsValue(annots, p); + std::unique_ptr annot(p); + return pdfium::ContainsValue(annots, annot); } CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { -- cgit v1.2.3