From a9caab94c1f16929e5acf2676117224617d80f53 Mon Sep 17 00:00:00 2001 From: tsepez Date: Wed, 14 Dec 2016 05:57:10 -0800 Subject: Avoid the ptr.reset(new XXX()) anti-pattern Be suspicious of |new|. This removes some of the easy cases. Review-Url: https://codereview.chromium.org/2571913002 --- xfa/fxfa/app/xfa_ffapp.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'xfa/fxfa/app/xfa_ffapp.cpp') diff --git a/xfa/fxfa/app/xfa_ffapp.cpp b/xfa/fxfa/app/xfa_ffapp.cpp index c264e03ec8..273b9f5b36 100644 --- a/xfa/fxfa/app/xfa_ffapp.cpp +++ b/xfa/fxfa/app/xfa_ffapp.cpp @@ -11,6 +11,7 @@ #include #include +#include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" #include "xfa/fgas/font/cfgas_fontmgr.h" #include "xfa/fwl/cfwl_notedriver.h" @@ -97,7 +98,7 @@ CXFA_FFApp::~CXFA_FFApp() {} CXFA_FFDocHandler* CXFA_FFApp::GetDocHandler() { if (!m_pDocHandler) - m_pDocHandler.reset(new CXFA_FFDocHandler); + m_pDocHandler = pdfium::MakeUnique(); return m_pDocHandler.get(); } @@ -120,7 +121,7 @@ CXFA_FFDoc* CXFA_FFApp::CreateDoc(IXFA_DocEnvironment* pDocEnvironment, void CXFA_FFApp::SetDefaultFontMgr(std::unique_ptr pFontMgr) { if (!m_pFontMgr) - m_pFontMgr.reset(new CXFA_FontMgr()); + m_pFontMgr = pdfium::MakeUnique(); m_pFontMgr->SetDefFontMgr(std::move(pFontMgr)); } @@ -133,7 +134,7 @@ CFGAS_FontMgr* CXFA_FFApp::GetFDEFontMgr() { #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ m_pFDEFontMgr = CFGAS_FontMgr::Create(FX_GetDefFontEnumerator()); #else - m_pFontSource.reset(new CFX_FontSourceEnum_File); + m_pFontSource = pdfium::MakeUnique(); m_pFDEFontMgr = CFGAS_FontMgr::Create(m_pFontSource.get()); #endif } @@ -142,14 +143,14 @@ CFGAS_FontMgr* CXFA_FFApp::GetFDEFontMgr() { CXFA_FWLTheme* CXFA_FFApp::GetFWLTheme() { if (!m_pFWLTheme) - m_pFWLTheme.reset(new CXFA_FWLTheme(this)); + m_pFWLTheme = pdfium::MakeUnique(this); return m_pFWLTheme.get(); } CXFA_FWLAdapterWidgetMgr* CXFA_FFApp::GetWidgetMgr( CFWL_WidgetMgrDelegate* pDelegate) { if (!m_pAdapterWidgetMgr) { - m_pAdapterWidgetMgr.reset(new CXFA_FWLAdapterWidgetMgr); + m_pAdapterWidgetMgr = pdfium::MakeUnique(); pDelegate->OnSetCapability(FWL_WGTMGR_DisableForm); m_pWidgetMgrDelegate = pDelegate; } -- cgit v1.2.3