Index: fpdfsdk/src/javascript/app.cpp |
diff --git a/fpdfsdk/src/javascript/app.cpp b/fpdfsdk/src/javascript/app.cpp |
index 248e50ecd4a17de4315694331850d183f24103c1..1466dc16a61c81cb1e3a1224059510e946ea2256 100644 |
--- a/fpdfsdk/src/javascript/app.cpp |
+++ b/fpdfsdk/src/javascript/app.cpp |
@@ -414,16 +414,10 @@ FX_BOOL app::setInterval(IFXJS_Context* cc, |
CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); |
ASSERT(pApp); |
- CJS_Timer* pTimer = new CJS_Timer(this, pApp); |
+ CJS_Timer* pTimer = |
+ new CJS_Timer(this, pApp, pRuntime, 0, script, dwInterval, 0); |
m_aTimer.Add(pTimer); |
- pTimer->SetType(0); |
- pTimer->SetRuntime(pRuntime); |
- pTimer->SetJScript(script); |
- pTimer->SetTimeOut(0); |
- // pTimer->SetStartTime(GetTickCount()); |
- pTimer->SetJSTimer(dwInterval); |
- |
v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj( |
pRuntime->GetIsolate(), pContext, |
FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj")); |
@@ -468,15 +462,10 @@ FX_BOOL app::setTimeOut(IFXJS_Context* cc, |
CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); |
ASSERT(pApp); |
- CJS_Timer* pTimer = new CJS_Timer(this, pApp); |
+ CJS_Timer* pTimer = |
+ new CJS_Timer(this, pApp, pRuntime, 1, script, dwTimeOut, dwTimeOut); |
m_aTimer.Add(pTimer); |
- pTimer->SetType(1); |
- pTimer->SetRuntime(pRuntime); |
- pTimer->SetJScript(script); |
- pTimer->SetTimeOut(dwTimeOut); |
- pTimer->SetJSTimer(dwTimeOut); |
- |
v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj( |
pRuntime->GetIsolate(), pContext, |
FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj")); |
@@ -591,13 +580,17 @@ FX_BOOL app::execMenuItem(IFXJS_Context* cc, |
void app::TimerProc(CJS_Timer* pTimer) { |
ASSERT(pTimer != NULL); |
+ CJS_Runtime* pRuntime = pTimer->GetRuntime(); |
+ |
switch (pTimer->GetType()) { |
case 0: // interval |
- RunJsScript(pTimer->GetRuntime(), pTimer->GetJScript()); |
+ if (pRuntime) |
+ RunJsScript(pRuntime, pTimer->GetJScript()); |
break; |
case 1: |
if (pTimer->GetTimeOut() > 0) { |
- RunJsScript(pTimer->GetRuntime(), pTimer->GetJScript()); |
+ if (pRuntime) |
+ RunJsScript(pRuntime, pTimer->GetJScript()); |
pTimer->KillJSTimer(); |
} |
break; |