From 1b4f6b36b3ed8d1f6cea96bc32c1b376f4a499bc Mon Sep 17 00:00:00 2001 From: weili Date: Thu, 4 Aug 2016 16:37:48 -0700 Subject: Use smart pointers for class owned pointers For classes under xfa/fgas, xfa/fwl/basewidget, and xfa/fwl/core, use smart pointers instead of raw pointer to make memory management easier. BUG=pdfium:518 Review-Url: https://codereview.chromium.org/2207093005 --- xfa/fwl/basewidget/fwl_editimp.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'xfa/fwl/basewidget/fwl_editimp.cpp') diff --git a/xfa/fwl/basewidget/fwl_editimp.cpp b/xfa/fwl/basewidget/fwl_editimp.cpp index ae0b7bcc9f..104054f4e1 100644 --- a/xfa/fwl/basewidget/fwl_editimp.cpp +++ b/xfa/fwl/basewidget/fwl_editimp.cpp @@ -203,7 +203,6 @@ CFWL_EditImp::CFWL_EditImp(const CFWL_WidgetImpProperties& properties, m_fVAlignOffset(0.0f), m_fScrollOffsetX(0.0f), m_fScrollOffsetY(0.0f), - m_pEdtEngine(nullptr), m_bLButtonDown(FALSE), m_nSelStart(0), m_nLimit(-1), @@ -223,7 +222,6 @@ CFWL_EditImp::CFWL_EditImp(const CFWL_WidgetImpProperties& properties, } CFWL_EditImp::~CFWL_EditImp() { - delete m_pEdtEngine; ClearRecord(); } @@ -898,26 +896,27 @@ void CFWL_EditImp::On_TextChanged(CFDE_TxtEdtEngine* pEdit, LayoutScrollBar(); Repaint(&rtTemp); } + void CFWL_EditImp::On_SelChanged(CFDE_TxtEdtEngine* pEdit) { CFX_RectF rtTemp; GetClientRect(rtTemp); Repaint(&rtTemp); } + FX_BOOL CFWL_EditImp::On_PageLoad(CFDE_TxtEdtEngine* pEdit, int32_t nPageIndex, int32_t nPurpose) { - CFDE_TxtEdtEngine* pEdtEngine = m_pEdtEngine; - IFDE_TxtEdtPage* pPage = pEdtEngine->GetPage(nPageIndex); + IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(nPageIndex); if (!pPage) return FALSE; pPage->LoadPage(nullptr, nullptr); return TRUE; } + FX_BOOL CFWL_EditImp::On_PageUnload(CFDE_TxtEdtEngine* pEdit, int32_t nPageIndex, int32_t nPurpose) { - CFDE_TxtEdtEngine* pEdtEngine = m_pEdtEngine; - IFDE_TxtEdtPage* pPage = pEdtEngine->GetPage(nPageIndex); + IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(nPageIndex); if (!pPage) return FALSE; pPage->UnloadPage(nullptr); @@ -1630,7 +1629,7 @@ void CFWL_EditImp::InitScrollBar(FX_BOOL bVert) { void CFWL_EditImp::InitEngine() { if (!m_pEdtEngine) - m_pEdtEngine = new CFDE_TxtEdtEngine; + m_pEdtEngine.reset(new CFDE_TxtEdtEngine); } FX_BOOL FWL_ShowCaret(IFWL_Widget* pWidget, -- cgit v1.2.3