summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/javascript/app.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/src/javascript/app.cpp')
-rw-r--r--fpdfsdk/src/javascript/app.cpp27
1 files changed, 10 insertions, 17 deletions
diff --git a/fpdfsdk/src/javascript/app.cpp b/fpdfsdk/src/javascript/app.cpp
index 9d4fa9ca13..067ae108bd 100644
--- a/fpdfsdk/src/javascript/app.cpp
+++ b/fpdfsdk/src/javascript/app.cpp
@@ -408,16 +408,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"));
@@ -462,15 +456,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"));
@@ -585,13 +574,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;