diff options
Diffstat (limited to 'xfa/fwl/cfwl_notedriver.cpp')
-rw-r--r-- | xfa/fwl/cfwl_notedriver.cpp | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/xfa/fwl/cfwl_notedriver.cpp b/xfa/fwl/cfwl_notedriver.cpp index 8feb0fb4e5..9012100c32 100644 --- a/xfa/fwl/cfwl_notedriver.cpp +++ b/xfa/fwl/cfwl_notedriver.cpp @@ -31,18 +31,12 @@ CFWL_NoteDriver::CFWL_NoteDriver() PushNoteLoop(m_pNoteLoop.get()); } -CFWL_NoteDriver::~CFWL_NoteDriver() { - ClearEventTargets(true); -} +CFWL_NoteDriver::~CFWL_NoteDriver() {} void CFWL_NoteDriver::SendEvent(CFWL_Event* pNote) { - if (m_eventTargets.empty()) - return; - for (const auto& pair : m_eventTargets) { - CFWL_EventTarget* pEventTarget = pair.second; - if (pEventTarget && !pEventTarget->IsInvalid()) - pEventTarget->ProcessEvent(pNote); + if (pair.second->IsValid()) + pair.second->ProcessEvent(pNote); } } @@ -56,7 +50,7 @@ void CFWL_NoteDriver::RegisterEventTarget(CFWL_Widget* pListener, pListener->SetEventKey(key); } if (!m_eventTargets[key]) - m_eventTargets[key] = new CFWL_EventTarget(pListener); + m_eventTargets[key] = pdfium::MakeUnique<CFWL_EventTarget>(pListener); m_eventTargets[key]->SetEventSource(pEventSource); } @@ -445,13 +439,11 @@ CFWL_Widget* CFWL_NoteDriver::GetMessageForm(CFWL_Widget* pDstTarget) { return pMessageForm; } -void CFWL_NoteDriver::ClearEventTargets(bool bRemoveAll) { +void CFWL_NoteDriver::ClearEventTargets() { auto it = m_eventTargets.begin(); while (it != m_eventTargets.end()) { auto old = it++; - if (old->second && (bRemoveAll || old->second->IsInvalid())) { - delete old->second; + if (!old->second->IsValid()) m_eventTargets.erase(old); - } } } |