summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2016-02-25 14:42:01 -0800
committerLei Zhang <thestig@chromium.org>2016-02-25 14:42:01 -0800
commit104fa7c879398c67cdaab3f7064ca9f6da07b072 (patch)
tree0b7dd72f5b37c8e275e15e53a19742155c5e1df6 /fpdfsdk
parentf8e21f34e9b67c5b9e754e949c58a5113ea4d746 (diff)
downloadpdfium-104fa7c879398c67cdaab3f7064ca9f6da07b072.tar.xz
Fix static initializers.
R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1725303003 .
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/include/fpdfxfa/fpdfxfa_util.h2
-rw-r--r--fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp24
2 files changed, 17 insertions, 9 deletions
diff --git a/fpdfsdk/include/fpdfxfa/fpdfxfa_util.h b/fpdfsdk/include/fpdfxfa/fpdfxfa_util.h
index 9678453db6..af69812471 100644
--- a/fpdfsdk/include/fpdfxfa/fpdfxfa_util.h
+++ b/fpdfsdk/include/fpdfxfa/fpdfxfa_util.h
@@ -31,7 +31,7 @@ class CXFA_FWLAdapterTimerMgr : public IFWL_AdapterTimerMgr {
protected:
static void TimerProc(int32_t idEvent);
- static std::vector<CFWL_TimerInfo*> s_TimerArray;
+ static std::vector<CFWL_TimerInfo*>* s_TimerArray;
CPDFDoc_Environment* const m_pEnv;
};
diff --git a/fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp b/fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp
index 03f1cfc358..c2a0db022c 100644
--- a/fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp
+++ b/fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp
@@ -8,7 +8,7 @@
#include "fpdfsdk/include/fsdk_define.h"
#include "fpdfsdk/include/fsdk_mgr.h"
-std::vector<CFWL_TimerInfo*> CXFA_FWLAdapterTimerMgr::s_TimerArray;
+std::vector<CFWL_TimerInfo*>* CXFA_FWLAdapterTimerMgr::s_TimerArray = nullptr;
FWL_ERR CXFA_FWLAdapterTimerMgr::Start(IFWL_Timer* pTimer,
FX_DWORD dwElapse,
@@ -18,8 +18,10 @@ FWL_ERR CXFA_FWLAdapterTimerMgr::Start(IFWL_Timer* pTimer,
return FWL_ERR_Indefinite;
uint32_t uIDEvent = m_pEnv->FFI_SetTimer(dwElapse, TimerProc);
- s_TimerArray.push_back(new CFWL_TimerInfo(uIDEvent, pTimer));
- hTimer = reinterpret_cast<FWL_HTIMER>(s_TimerArray.back());
+ if (!s_TimerArray)
+ s_TimerArray = new std::vector<CFWL_TimerInfo*>;
+ s_TimerArray->push_back(new CFWL_TimerInfo(uIDEvent, pTimer));
+ hTimer = reinterpret_cast<FWL_HTIMER>(s_TimerArray->back());
return FWL_ERR_Succeeded;
}
@@ -29,16 +31,22 @@ FWL_ERR CXFA_FWLAdapterTimerMgr::Stop(FWL_HTIMER hTimer) {
CFWL_TimerInfo* pInfo = reinterpret_cast<CFWL_TimerInfo*>(hTimer);
m_pEnv->FFI_KillTimer(pInfo->uIDEvent);
- auto it = std::find(s_TimerArray.begin(), s_TimerArray.end(), pInfo);
- if (it != s_TimerArray.end()) {
- s_TimerArray.erase(it);
- delete pInfo;
+ if (s_TimerArray) {
+ auto it = std::find(s_TimerArray->begin(), s_TimerArray->end(), pInfo);
+ if (it != s_TimerArray->end()) {
+ s_TimerArray->erase(it);
+ delete pInfo;
+ }
}
return FWL_ERR_Succeeded;
}
+// static
void CXFA_FWLAdapterTimerMgr::TimerProc(int32_t idEvent) {
- for (CFWL_TimerInfo* pInfo : s_TimerArray) {
+ if (!s_TimerArray)
+ return;
+
+ for (CFWL_TimerInfo* pInfo : *s_TimerArray) {
if (pInfo->uIDEvent == idEvent) {
pInfo->pTimer->Run(reinterpret_cast<FWL_HTIMER>(pInfo));
break;