From f74ad998d2e8d2636fb25e94823946a3b151e34e Mon Sep 17 00:00:00 2001 From: tsepez Date: Wed, 11 May 2016 10:26:05 -0700 Subject: Replace some calls to Release() with direct delete, part 1. Searching for the anti-pattern: void Release() { delete this; } We must be explicit on the ownership model. Add unique_ptrs as a result. Review-Url: https://codereview.chromium.org/1960673003 --- xfa/fxfa/app/xfa_fwltheme.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'xfa/fxfa/app/xfa_fwltheme.cpp') diff --git a/xfa/fxfa/app/xfa_fwltheme.cpp b/xfa/fxfa/app/xfa_fwltheme.cpp index fac873cac9..df09fb504a 100644 --- a/xfa/fxfa/app/xfa_fwltheme.cpp +++ b/xfa/fxfa/app/xfa_fwltheme.cpp @@ -44,7 +44,6 @@ CXFA_FFWidget* XFA_ThemeGetOuterWidget(IFWL_Widget* pWidget) { return NULL; } CXFA_FWLTheme::CXFA_FWLTheme(CXFA_FFApp* pApp) : m_pApp(pApp) { - m_pTextOut = NULL; m_dwCapacity = 0; m_fCapacity = 0; m_pCalendarFont = NULL; @@ -77,7 +76,7 @@ CXFA_FWLTheme::~CXFA_FWLTheme() { delete m_pBarcodeTP; } FWL_Error CXFA_FWLTheme::Initialize() { - m_pTextOut = new CFDE_TextOut; + m_pTextOut.reset(new CFDE_TextOut); for (size_t i = 0; !m_pCalendarFont && i < FX_ArraySize(g_FWLTheme_CalFonts); ++i) { m_pCalendarFont = IFX_Font::LoadFont(g_FWLTheme_CalFonts[i], 0, 0, @@ -98,13 +97,10 @@ FWL_Error CXFA_FWLTheme::Initialize() { return FWL_Error::Succeeded; } FWL_Error CXFA_FWLTheme::Finalize() { - if (m_pTextOut) { - m_pTextOut->Release(); - m_pTextOut = NULL; - } + m_pTextOut.reset(); if (m_pCalendarFont) { m_pCalendarFont->Release(); - m_pCalendarFont = NULL; + m_pCalendarFont = nullptr; } FWLTHEME_Release(); return FWL_Error::Succeeded; @@ -386,8 +382,6 @@ FX_BOOL CXFA_FWLTheme::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) { m_pTextOut->SetTextColor(pAcc->GetTextColor()); if (!pParams) return FALSE; - if (!m_pTextOut) - return FALSE; m_pTextOut->SetAlignment(pParams->m_iTTOAlign); m_pTextOut->SetStyles(pParams->m_dwTTOStyles); m_pTextOut->CalcLogicSize(pParams->m_wsText.c_str(), -- cgit v1.2.3