From 75560afd066b5a7e8f050232964bb013fa355f83 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 14 Sep 2018 23:15:08 +0000 Subject: Use MakeUnique() in CFFL_InteractiveFormFiller. Remove more bare |new|s. Change-Id: Ia26bb8150d5bb0004c6a8e6ff89b4694b9ef2865 Reviewed-on: https://pdfium-review.googlesource.com/42552 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- fpdfsdk/formfiller/cffl_interactiveformfiller.cpp | 26 ++++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp index c1cc355156..7feda490ba 100644 --- a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp +++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp @@ -476,37 +476,43 @@ CFFL_FormFiller* CFFL_InteractiveFormFiller::GetFormFiller( CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot); FormFieldType fieldType = pWidget->GetFieldType(); - CFFL_FormFiller* pFormFiller; + std::unique_ptr pFormFiller; switch (fieldType) { case FormFieldType::kPushButton: - pFormFiller = new CFFL_PushButton(m_pFormFillEnv.Get(), pWidget); + pFormFiller = + pdfium::MakeUnique(m_pFormFillEnv.Get(), pWidget); break; case FormFieldType::kCheckBox: - pFormFiller = new CFFL_CheckBox(m_pFormFillEnv.Get(), pWidget); + pFormFiller = + pdfium::MakeUnique(m_pFormFillEnv.Get(), pWidget); break; case FormFieldType::kRadioButton: - pFormFiller = new CFFL_RadioButton(m_pFormFillEnv.Get(), pWidget); + pFormFiller = + pdfium::MakeUnique(m_pFormFillEnv.Get(), pWidget); break; case FormFieldType::kTextField: - pFormFiller = new CFFL_TextField(m_pFormFillEnv.Get(), pWidget); + pFormFiller = + pdfium::MakeUnique(m_pFormFillEnv.Get(), pWidget); break; case FormFieldType::kListBox: - pFormFiller = new CFFL_ListBox(m_pFormFillEnv.Get(), pWidget); + pFormFiller = + pdfium::MakeUnique(m_pFormFillEnv.Get(), pWidget); break; case FormFieldType::kComboBox: - pFormFiller = new CFFL_ComboBox(m_pFormFillEnv.Get(), pWidget); + pFormFiller = + pdfium::MakeUnique(m_pFormFillEnv.Get(), pWidget); break; case FormFieldType::kUnknown: default: - pFormFiller = nullptr; break; } if (!pFormFiller) return nullptr; - m_Maps[pAnnot].reset(pFormFiller); - return pFormFiller; + CFFL_FormFiller* result = pFormFiller.get(); + m_Maps[pAnnot] = std::move(pFormFiller); + return result; } WideString CFFL_InteractiveFormFiller::GetText(CPDFSDK_Annot* pAnnot) { -- cgit v1.2.3