static DWORD WINAPI scriptRunThread(void* arg) { int destline = (int)(uint)arg; if(!destline || destline > (int)linemap.size()) //invalid line destline = 0; if(destline) { destline = scriptinternalstep(destline - 1); //no breakpoints on non-executable locations if(!scriptinternalbpget(destline)) //no breakpoint set scriptinternalbptoggle(destline); } bAbort = false; if(scriptIp) scriptIp--; scriptIp = scriptinternalstep(scriptIp); bool bContinue = true; while(bContinue && !bAbort) //run loop { bContinue = scriptinternalcmd(); if(scriptIp == scriptinternalstep(scriptIp)) //end of script { bContinue = false; scriptIp = scriptinternalstep(0); } if(bContinue) scriptIp = scriptinternalstep(scriptIp); //this is the next ip if(scriptinternalbpget(scriptIp)) //breakpoint=stop run loop bContinue = false; Sleep(1); //don't fry the processor } bIsRunning = false; //not running anymore GuiScriptSetIp(scriptIp); return 0; }
DWORD WINAPI scriptRunSync(void* arg) { int destline = (int)(duint)arg; if(!destline || destline > (int)linemap.size()) //invalid line destline = 0; if(destline) { destline = scriptinternalstep(destline - 1); //no breakpoints on non-executable locations if(!scriptinternalbpget(destline)) //no breakpoint set scriptinternalbptoggle(destline); } bAbort = false; if(scriptIp) scriptIp--; scriptIp = scriptinternalstep(scriptIp); bool bContinue = true; bool bIgnoreTimeout = settingboolget("Engine", "NoScriptTimeout"); unsigned long long kernelTime, userTime; FILETIME creationTime, exitTime; // unused while(bContinue && !bAbort) //run loop { bContinue = scriptinternalcmd(); if(scriptIp == scriptinternalstep(scriptIp)) //end of script { bContinue = false; scriptIp = scriptinternalstep(0); } if(bContinue) scriptIp = scriptinternalstep(scriptIp); //this is the next ip if(scriptinternalbpget(scriptIp)) //breakpoint=stop run loop bContinue = false; if(bContinue && !bIgnoreTimeout && GetThreadTimes(GetCurrentThread(), &creationTime, &exitTime, reinterpret_cast<LPFILETIME>(&kernelTime), reinterpret_cast<LPFILETIME>(&userTime)) != 0) { if(userTime + kernelTime >= 10 * 10000000) // time out in 10 seconds of CPU time { if(GuiScriptMsgyn(GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "The script is too busy. Would you like to terminate it now?"))) != 0) { dputs(QT_TRANSLATE_NOOP("DBG", "Script is terminated by user.")); break; } else bIgnoreTimeout = true; } } } bIsRunning = false; //not running anymore GuiScriptSetIp(scriptIp); return 0; }