fixed JS infinite loop check

This commit is contained in:
BADIM-PC\Vadim 2018-02-15 20:45:43 +03:00
parent 17ac8d2ab2
commit a2d961f060
2 changed files with 5 additions and 10 deletions

2
.gitignore vendored
View File

@ -109,3 +109,5 @@ build/uwp/studio/Debug/
build/uwp/studio/Debug Pro/
build/uwp/studio/Release/
build/uwp/studio/Release Pro/
build/uwp/studio/ARM/
build/uwp/studio/x64/

View File

@ -824,22 +824,13 @@ s32 duk_timeout_check(void* udata)
tic_machine* machine = (tic_machine*)udata;
tic_tick_data* tick = machine->data;
enum{Wait = 1000}; // 1 sec
if(ForceExitCounter)
return ForceExitCounter < tick->counter();
else if(tick->forceExit && tick->forceExit(tick->data))
ForceExitCounter = tick->counter() + Wait * 1000 / tick->freq();
return false;
return ForceExitCounter++ > 1000 ? tick->forceExit && tick->forceExit(tick->data) : false;
}
static void initDuktape(tic_machine* machine)
{
closeJavascript((tic_mem*)machine);
ForceExitCounter = 0;
duk_context* duk = machine->js = duk_create_heap(NULL, NULL, NULL, machine, NULL);
{
@ -876,6 +867,8 @@ static bool initJavascript(tic_mem* tic, const char* code)
static void callJavascriptTick(tic_mem* tic)
{
ForceExitCounter = 0;
tic_machine* machine = (tic_machine*)tic;
const char* TicFunc = ApiKeywords[0];