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

Unified Diff: fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp

Issue 1725303003: Fix static initializers. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 4 years, 10 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 | « fpdfsdk/include/fpdfxfa/fpdfxfa_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp
diff --git a/fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp b/fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp
index 03f1cfc3581e77896c1d1bc9a4793250a2d916e1..c2a0db022c16be625ee8c96dbf45437b48bb778c 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;
« no previous file with comments | « fpdfsdk/include/fpdfxfa/fpdfxfa_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698