From 606346f584700bdae0741066f2e6d2481744032c Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 19 Jun 2015 18:11:07 -0700 Subject: Merge to XFA: Replace some CFX_MapPtrTemplates with std::map. There are more CFX_MapPtrTemplate usage on the XFA branch, so it is not removed. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1181593003. (cherry picked from commit e8d3691c82d1be805ffdce3329d00313af7ce0ab) Review URL: https://codereview.chromium.org/1198663004. --- fpdfsdk/src/pdfwindow/PWL_Wnd.cpp | 44 ++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'fpdfsdk/src/pdfwindow') diff --git a/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp b/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp index dcc6e409a4..89d4babcd7 100644 --- a/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp +++ b/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "../../include/pdfwindow/PDFWindow.h" #include "../../include/pdfwindow/PWL_Wnd.h" #include "../../include/pdfwindow/PWL_Utils.h" @@ -11,10 +13,10 @@ /* -------------------------- CPWL_Timer -------------------------- */ -static CFX_MapPtrTemplate& GetPWLTimeMap() +static std::map& GetPWLTimeMap() { // Leak the object at shutdown. - static auto timeMap = new CFX_MapPtrTemplate; + static auto timeMap = new std::map; return *timeMap; } @@ -34,33 +36,33 @@ CPWL_Timer::~CPWL_Timer() int32_t CPWL_Timer::SetPWLTimer(int32_t nElapse) { - if (m_nTimerID != 0) KillPWLTimer(); - m_nTimerID = m_pSystemHandler->SetTimer(nElapse, TimerProc); - GetPWLTimeMap().SetAt(m_nTimerID, this); - return m_nTimerID; + if (m_nTimerID != 0) + KillPWLTimer(); + m_nTimerID = m_pSystemHandler->SetTimer(nElapse, TimerProc); + + GetPWLTimeMap()[m_nTimerID] = this; + return m_nTimerID; } void CPWL_Timer::KillPWLTimer() { - if (m_nTimerID != 0) - { - m_pSystemHandler->KillTimer(m_nTimerID); - GetPWLTimeMap().RemoveKey(m_nTimerID); - m_nTimerID = 0; - } + if (m_nTimerID == 0) + return; + + m_pSystemHandler->KillTimer(m_nTimerID); + GetPWLTimeMap().erase(m_nTimerID); + m_nTimerID = 0; } void CPWL_Timer::TimerProc(int32_t idEvent) { - CPWL_Timer* pTimer = NULL; - if (GetPWLTimeMap().Lookup(idEvent, pTimer)) - { - if (pTimer) - { - if (pTimer->m_pAttached) - pTimer->m_pAttached->TimerProc(); - } - } + auto it = GetPWLTimeMap().find(idEvent); + if (it == GetPWLTimeMap().end()) + return; + + CPWL_Timer* pTimer = it->second; + if (pTimer->m_pAttached) + pTimer->m_pAttached->TimerProc(); } /* -------------------------- CPWL_TimerHandler -------------------------- */ -- cgit v1.2.3