From cc4d6d85b58a7a1d9d7b798c63d3343f3dac06a9 Mon Sep 17 00:00:00 2001 From: tsepez Date: Mon, 16 May 2016 13:21:03 -0700 Subject: Remove { delete this; } anti-pattern from IXFA_WidgetIterator Review-Url: https://codereview.chromium.org/1976123003 --- fpdfsdk/fsdk_annothandler.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'fpdfsdk/fsdk_annothandler.cpp') diff --git a/fpdfsdk/fsdk_annothandler.cpp b/fpdfsdk/fsdk_annothandler.cpp index 73701cfb4c..db2d20b2bf 100644 --- a/fpdfsdk/fsdk_annothandler.cpp +++ b/fpdfsdk/fsdk_annothandler.cpp @@ -376,22 +376,20 @@ CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, return pNext; } // for xfa annots - IXFA_WidgetIterator* pWidgetIterator = + std::unique_ptr pWidgetIterator( pPage->GetXFAPageView()->CreateWidgetIterator( XFA_TRAVERSEWAY_Tranvalse, XFA_WIDGETFILTER_Visible | XFA_WIDGETFILTER_Viewable | - XFA_WIDGETFILTER_Field); - if (pWidgetIterator == NULL) - return NULL; + XFA_WIDGETFILTER_Field)); + if (!pWidgetIterator) + return nullptr; if (pWidgetIterator->GetCurrentWidget() != pSDKAnnot->GetXFAWidget()) pWidgetIterator->SetCurrentWidget(pSDKAnnot->GetXFAWidget()); - CXFA_FFWidget* hNextFocus = NULL; - hNextFocus = + CXFA_FFWidget* hNextFocus = bNext ? pWidgetIterator->MoveToNext() : pWidgetIterator->MoveToPrevious(); if (!hNextFocus && pSDKAnnot) hNextFocus = pWidgetIterator->MoveToFirst(); - pWidgetIterator->Release(); return pPageView->GetAnnotByXFAWidget(hNextFocus); #else // PDF_ENABLE_XFA CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget", ""); -- cgit v1.2.3