diff options
author | dsinclair <dsinclair@chromium.org> | 2016-11-16 17:55:09 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-11-16 17:55:09 -0800 |
commit | 038a23f297963997d631d91fefdf97598585f3ba (patch) | |
tree | b6953d33c694e143ba006f0635f94ae6d3158b69 /xfa | |
parent | 5913a6ca71c85401e3f5317758d44a9fc4a667b2 (diff) | |
download | pdfium-038a23f297963997d631d91fefdf97598585f3ba.tar.xz |
Remove ref counting from CFWL_Event
CFWL_Event has no Retain method, just a Release method. So, it's essentially
just a delete call whenever used. This CL removes the Release method and turns
the one usage into a unique_ptr.
Review-Url: https://codereview.chromium.org/2509863002
Diffstat (limited to 'xfa')
-rw-r--r-- | xfa/fwl/core/cfwl_event.h | 15 | ||||
-rw-r--r-- | xfa/fwl/core/ifwl_widget.cpp | 5 |
2 files changed, 3 insertions, 17 deletions
diff --git a/xfa/fwl/core/cfwl_event.h b/xfa/fwl/core/cfwl_event.h index e7bc15ad58..a20abaa2a2 100644 --- a/xfa/fwl/core/cfwl_event.h +++ b/xfa/fwl/core/cfwl_event.h @@ -78,17 +78,12 @@ class CFWL_Event { virtual CFWL_EventType GetClassID() const; - uint32_t Release(); - IFWL_Widget* m_pSrcTarget; IFWL_Widget* m_pDstTarget; - - private: - uint32_t m_dwRefCount; }; inline CFWL_Event::CFWL_Event() - : m_pSrcTarget(nullptr), m_pDstTarget(nullptr), m_dwRefCount(1) {} + : m_pSrcTarget(nullptr), m_pDstTarget(nullptr) {} inline CFWL_Event::~CFWL_Event() {} @@ -96,14 +91,6 @@ inline CFWL_EventType CFWL_Event::GetClassID() const { return CFWL_EventType::None; } -inline uint32_t CFWL_Event::Release() { - m_dwRefCount--; - uint32_t dwRefCount = m_dwRefCount; - if (!m_dwRefCount) - delete this; - return dwRefCount; -} - #define FWL_EVENT_DEF(classname, eventType, ...) \ class classname : public CFWL_Event { \ public: \ diff --git a/xfa/fwl/core/ifwl_widget.cpp b/xfa/fwl/core/ifwl_widget.cpp index f8288eb0e4..454f4833fd 100644 --- a/xfa/fwl/core/ifwl_widget.cpp +++ b/xfa/fwl/core/ifwl_widget.cpp @@ -551,13 +551,12 @@ void IFWL_Widget::DispatchKeyEvent(CFWL_MsgKey* pNote) { if (!pNote) return; - CFWL_EvtKey* pEvent = new CFWL_EvtKey; + auto pEvent = pdfium::MakeUnique<CFWL_EvtKey>(); pEvent->m_pSrcTarget = this; pEvent->m_dwCmd = pNote->m_dwCmd; pEvent->m_dwKeyCode = pNote->m_dwKeyCode; pEvent->m_dwFlags = pNote->m_dwFlags; - DispatchEvent(pEvent); - pEvent->Release(); + DispatchEvent(pEvent.get()); } void IFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { |