Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Unified Diff: fpdfsdk/src/pdfwindow/PWL_Wnd.cpp

Issue 832703003: Get rid of g_timeMap global object. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Adding clarifying comment. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/src/pdfwindow/PWL_Wnd.cpp
diff --git a/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp b/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp
index bc3348736bdc2996dcf4694b5a830d293dced8f5..69535d7d85977fdd5784ce644f6f25c8a85c31e5 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp
@@ -11,7 +11,12 @@
/* -------------------------- CPWL_Timer -------------------------- */
-static CFX_MapPtrTemplate<FX_INT32, CPWL_Timer*> g_TimeMap;
+static CFX_MapPtrTemplate<FX_INT32, CPWL_Timer*>& GetPWLTimeMap()
+{
+ // Leak the object at shutdown.
+ static auto timeMap = new CFX_MapPtrTemplate<FX_INT32, CPWL_Timer*>;
+ return *timeMap;
+}
CPWL_Timer::CPWL_Timer(CPWL_TimerHandler* pAttached, IFX_SystemHandler* pSystemHandler) :
m_nTimerID(0),
@@ -31,7 +36,7 @@ FX_INT32 CPWL_Timer::SetPWLTimer(FX_INT32 nElapse)
{
if (m_nTimerID != 0) KillPWLTimer();
m_nTimerID = m_pSystemHandler->SetTimer(nElapse, TimerProc);
- g_TimeMap.SetAt(m_nTimerID, this);
+ GetPWLTimeMap().SetAt(m_nTimerID, this);
return m_nTimerID;
}
@@ -40,7 +45,7 @@ void CPWL_Timer::KillPWLTimer()
if (m_nTimerID != 0)
{
m_pSystemHandler->KillTimer(m_nTimerID);
- g_TimeMap.RemoveKey(m_nTimerID);
+ GetPWLTimeMap().RemoveKey(m_nTimerID);
m_nTimerID = 0;
}
}
@@ -48,7 +53,7 @@ void CPWL_Timer::KillPWLTimer()
void CPWL_Timer::TimerProc(FX_INT32 idEvent)
{
CPWL_Timer* pTimer = NULL;
- if (g_TimeMap.Lookup(idEvent, pTimer))
+ if (GetPWLTimeMap().Lookup(idEvent, pTimer))
{
if (pTimer)
{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698