QtIsCute
20th July 2012, 16:49
Hello,
I have an application, in which a thread is executing a qscript function
ExecuteThread::ExecuteThread(QString code, QObject *parent) :
QThread(parent)
{
this->code = code;
this->result = 0;
ExecuteEngine = new QScriptEngine();
}
void ExecuteThread::run(){
ExecuteEngine = new QScriptEngine();
QScriptValue fun = ExecuteEngine->evaluate("(" + code + ")");
QScriptValue val = fun.call();
result = val.toInteger();
delete ExecuteEngine;
}
int ExecuteThread::getResult(){
return result;
}
void ExecuteThread::stop(){
ExecuteEngine->abortEvaluation(QScriptValue(-100));
exit(0);
}
Everything works fine, until there is an infinte loop in the QScript-function, then the thread stops at fun.call() and I can't delete the thread any more neither after calling stop() nor calling terminate(). Could you please tell me what I have to do in this case?
I have an application, in which a thread is executing a qscript function
ExecuteThread::ExecuteThread(QString code, QObject *parent) :
QThread(parent)
{
this->code = code;
this->result = 0;
ExecuteEngine = new QScriptEngine();
}
void ExecuteThread::run(){
ExecuteEngine = new QScriptEngine();
QScriptValue fun = ExecuteEngine->evaluate("(" + code + ")");
QScriptValue val = fun.call();
result = val.toInteger();
delete ExecuteEngine;
}
int ExecuteThread::getResult(){
return result;
}
void ExecuteThread::stop(){
ExecuteEngine->abortEvaluation(QScriptValue(-100));
exit(0);
}
Everything works fine, until there is an infinte loop in the QScript-function, then the thread stops at fun.call() and I can't delete the thread any more neither after calling stop() nor calling terminate(). Could you please tell me what I have to do in this case?