summaryrefslogtreecommitdiff
path: root/xfa/fwl/cfwl_notedriver.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-04-18 11:45:36 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-04-18 19:19:22 +0000
commit1d52d1e5fb0b14782dd6b97eeee8c90106839452 (patch)
tree66f794d6559c0bd2ddd4dab2272ceabf01426fdc /xfa/fwl/cfwl_notedriver.cpp
parenta77572303624a9ba9877f432bcb6ee2a16b9b34e (diff)
downloadpdfium-1d52d1e5fb0b14782dd6b97eeee8c90106839452.tar.xz
Use unique_ptr in CFWL_NoteDriver::m_eventTargets map
Invert CFWL_EventTarget::m_bInvalid for the sake of positive logic. Change-Id: I9ccc512ab2ff553e1033698f36bf3a297c4ee7c9 Reviewed-on: https://pdfium-review.googlesource.com/4251 Commit-Queue: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fwl/cfwl_notedriver.cpp')
-rw-r--r--xfa/fwl/cfwl_notedriver.cpp20
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);
- }
}
}