Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to abort QJSEngine evaluation

Tags:

c++

qt

qml

If evaluate some script that has infinite loop, how to abort the evaluation process.

for example: evaluate some buggy JS in back thread:

QJSEngine engine;

void threadproc() {
    engine.evaluate("while(1){}");
}

How to give user a choice to abort the evaluate in main(GUI) thread.

like image 910
tomnotcat Avatar asked Nov 09 '22 02:11

tomnotcat


1 Answers

Introduced in Qt 5.14 are new QJSEngine methods to help abort infinite running executions:

  • https://doc.qt.io/qt-5/qjsengine.html#isInterrupted
  • https://doc.qt.io/qt-5/qjsengine.html#setInterrupted
like image 90
Stephen Quan Avatar answered Nov 14 '22 21:11

Stephen Quan