From fe91c6c8211cec39f871d9202556e1957bf81983 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 16 May 2017 15:33:20 -0700 Subject: Be skeptical of bare |new|s. In particular, prefer an explicit .release() call when handing ownership of an object to a caller across a C-API. Change-Id: Ic3784e9d0b2d378a08d388989eaea7c9166bacd1 Reviewed-on: https://pdfium-review.googlesource.com/5470 Commit-Queue: Tom Sepez Reviewed-by: Lei Zhang --- fpdfsdk/formfiller/cffl_combobox.cpp | 14 +++++--------- fpdfsdk/formfiller/cffl_combobox.h | 4 +++- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'fpdfsdk/formfiller') diff --git a/fpdfsdk/formfiller/cffl_combobox.cpp b/fpdfsdk/formfiller/cffl_combobox.cpp index ef05a883c9..1f2491fe95 100644 --- a/fpdfsdk/formfiller/cffl_combobox.cpp +++ b/fpdfsdk/formfiller/cffl_combobox.cpp @@ -13,10 +13,11 @@ #include "fpdfsdk/formfiller/cffl_interactiveformfiller.h" #include "fpdfsdk/fsdk_common.h" #include "fpdfsdk/pdfwindow/PWL_ComboBox.h" +#include "third_party/base/ptr_util.h" CFFL_ComboBox::CFFL_ComboBox(CPDFSDK_FormFillEnvironment* pApp, CPDFSDK_Annot* pAnnot) - : CFFL_FormFiller(pApp, pAnnot), m_pFontMap(nullptr) { + : CFFL_FormFiller(pApp, pAnnot) { m_State.nIndex = 0; m_State.nStart = 0; m_State.nEnd = 0; @@ -30,22 +31,17 @@ CFFL_ComboBox::~CFFL_ComboBox() { // The font map should be stored somewhere more appropriate so it will live // until the PWL_Edit is done with it. pdfium:566 DestroyWindows(); - delete m_pFontMap; } PWL_CREATEPARAM CFFL_ComboBox::GetCreateParam() { PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam(); - - int nFlags = m_pWidget->GetFieldFlags(); - if (nFlags & FIELDFLAG_EDIT) { + if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT) cp.dwFlags |= PCBS_ALLOWCUSTOMTEXT; - } if (!m_pFontMap) - m_pFontMap = new CBA_FontMap(m_pWidget, GetSystemHandler()); - cp.pFontMap = m_pFontMap; + m_pFontMap = pdfium::MakeUnique(m_pWidget, GetSystemHandler()); + cp.pFontMap = m_pFontMap.get(); cp.pFocusHandler = this; - return cp; } diff --git a/fpdfsdk/formfiller/cffl_combobox.h b/fpdfsdk/formfiller/cffl_combobox.h index aab10b90e1..e61e2b73c3 100644 --- a/fpdfsdk/formfiller/cffl_combobox.h +++ b/fpdfsdk/formfiller/cffl_combobox.h @@ -7,6 +7,8 @@ #ifndef FPDFSDK_FORMFILLER_CFFL_COMBOBOX_H_ #define FPDFSDK_FORMFILLER_CFFL_COMBOBOX_H_ +#include + #include "core/fxcrt/fx_string.h" #include "fpdfsdk/formfiller/cffl_formfiller.h" @@ -56,7 +58,7 @@ class CFFL_ComboBox : public CFFL_FormFiller, public IPWL_FocusHandler { private: CFX_WideString GetSelectExportText(); - CBA_FontMap* m_pFontMap; + std::unique_ptr m_pFontMap; FFL_ComboBoxState m_State; }; -- cgit v1.2.3