From 6fe8795d9022105a0061a0a81be9a49d49fda345 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Tue, 1 Nov 2016 18:48:19 -0700 Subject: Fold IFWL*::{Initialize|Finalize} into constructor/destructor This Cl moves the ::Initialize method into the constructors and the ::Finalize method into the destructors. The |m_pDelegate| is made private and a unique_ptr. A |SetDelegate| and |GetDelegate| method are added. Review-Url: https://codereview.chromium.org/2464703006 --- xfa/fwl/core/ifwl_widget.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'xfa/fwl/core/ifwl_widget.cpp') diff --git a/xfa/fwl/core/ifwl_widget.cpp b/xfa/fwl/core/ifwl_widget.cpp index da90c4892d..961c02497b 100644 --- a/xfa/fwl/core/ifwl_widget.cpp +++ b/xfa/fwl/core/ifwl_widget.cpp @@ -30,7 +30,6 @@ IFWL_Widget::IFWL_Widget(const IFWL_App* app, : m_pOwnerApp(app), m_pWidgetMgr(app->GetWidgetMgr()), m_pProperties(new CFWL_WidgetImpProperties(properties)), - m_pDelegate(nullptr), m_pCurDelegate(nullptr), m_pOuter(pOuter), m_pLayoutItem(nullptr), @@ -38,21 +37,18 @@ IFWL_Widget::IFWL_Widget(const IFWL_App* app, m_iLock(0), m_nEventKey(0) { ASSERT(m_pWidgetMgr); -} - -IFWL_Widget::~IFWL_Widget() {} -void IFWL_Widget::Initialize() { IFWL_Widget* pParent = m_pProperties->m_pParent; m_pWidgetMgr->InsertWidget(pParent, this); - if (!IsChild()) { - IFWL_Widget* pOwner = m_pProperties->m_pOwner; - if (pOwner) - m_pWidgetMgr->SetOwner(pOwner, this); - } + if (IsChild()) + return; + + IFWL_Widget* pOwner = m_pProperties->m_pOwner; + if (pOwner) + m_pWidgetMgr->SetOwner(pOwner, this); } -void IFWL_Widget::Finalize() { +IFWL_Widget::~IFWL_Widget() { NotifyDriver(); m_pWidgetMgr->RemoveWidget(this); } @@ -354,7 +350,7 @@ FWL_Error IFWL_Widget::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { IFWL_WidgetDelegate* IFWL_Widget::GetCurrentDelegate() { if (!m_pCurDelegate) - m_pCurDelegate = m_pDelegate; + m_pCurDelegate = m_pDelegate.get(); return m_pCurDelegate; } -- cgit v1.2.3