diff options
-rw-r--r-- | fpdfsdk/include/javascript/JS_Object.h | 8 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_Object.cpp | 7 |
2 files changed, 11 insertions, 4 deletions
diff --git a/fpdfsdk/include/javascript/JS_Object.h b/fpdfsdk/include/javascript/JS_Object.h index ca6f4a1d11..7bdfcf1a53 100644 --- a/fpdfsdk/include/javascript/JS_Object.h +++ b/fpdfsdk/include/javascript/JS_Object.h @@ -157,7 +157,7 @@ public: CTimerMapArray m_Array; }; -static JS_TIMER_MAPARRAY m_sTimeMap; +JS_TIMER_MAPARRAY& GetTimeMap(); class CJS_Runtime; @@ -188,7 +188,7 @@ public: if (m_nTimerID)KillJSTimer(); IFX_SystemHandler* pHandler = m_pApp->GetSysHandler(); m_nTimerID = pHandler->SetTimer(nElapse,TimerProc); - m_sTimeMap.SetAt(m_nTimerID,this); + GetTimeMap().SetAt(m_nTimerID,this); m_dwElapse = nElapse; return m_nTimerID; }; @@ -204,7 +204,7 @@ public: } IFX_SystemHandler* pHandler = m_pApp->GetSysHandler(); pHandler->KillTimer(m_nTimerID); - m_sTimeMap.RemoveAt(m_nTimerID); + GetTimeMap().RemoveAt(m_nTimerID); m_nTimerID = 0; } }; @@ -261,7 +261,7 @@ public: static void TimerProc(int idEvent) { - if (CJS_Timer * pTimer = m_sTimeMap.GetAt(idEvent)) + if (CJS_Timer * pTimer = GetTimeMap().GetAt(idEvent)) { if (!pTimer->m_bProcessing) { diff --git a/fpdfsdk/src/javascript/JS_Object.cpp b/fpdfsdk/src/javascript/JS_Object.cpp index 09150e796b..34ad8e1f0a 100644 --- a/fpdfsdk/src/javascript/JS_Object.cpp +++ b/fpdfsdk/src/javascript/JS_Object.cpp @@ -12,6 +12,13 @@ // #include "../../include/javascript/JS_ResMgr.h" #include "../../include/javascript/JS_Context.h" +JS_TIMER_MAPARRAY& GetTimeMap() +{ + // Leak the timer array at shutdown. + static auto* timeMap = new JS_TIMER_MAPARRAY; + return *timeMap; +} + int FXJS_MsgBox(CPDFDoc_Environment* pApp, CPDFSDK_PageView* pPageView, FX_LPCWSTR swMsg, FX_LPCWSTR swTitle, FX_UINT nType, FX_UINT nIcon) { int nRet = 0; |