Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(783)

Unified Diff: fpdfsdk/fsdk_annothandler.cpp

Issue 1976123003: Remove { delete this; } anti-pattern from IXFA_WidgetIterator (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: fpdfsdk/fsdk_annothandler.cpp
diff --git a/fpdfsdk/fsdk_annothandler.cpp b/fpdfsdk/fsdk_annothandler.cpp
index 73701cfb4cefe2f3ad9872439c200fb62dd9dd0d..db2d20b2bfb5dee865b2eed58957c3a6901ab044 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<IXFA_WidgetIterator> 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", "");
« no previous file with comments | « fpdfsdk/fpdfformfill.cpp ('k') | fpdfsdk/fsdk_mgr.cpp » ('j') | fpdfsdk/fsdk_mgr.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698