我在我的应用程序中使用 QtScript。脚本由用户编写。作为这样的示例脚本:
//<init test time counters>
function testIteration() {
if (<test time is out>) {
myCppObject.mySignalAllDone.disconnect(testIteration);//disconnection
return;
}
//<Adding actions to myCppObject>
}
myCppObject.mySignalAllDone.connect(testIteration);//connection
testIteration();
我想在测试时间过去之前从 C++ 停止这个脚本并编写这样的函数
void MainWindow::toolButtonStopScript_clicked(){
disconnect(&this->myCppObject);// Disconnecting everything connected to myCppObject.
this->scriptEngineThread.abortAllEvaluations();
myCppObject.stopAllActivity();// emits mySignalAllDone, that is not disconnected (why and how to do that if I don't know what connections user made?), calling testIteration(), appending activity to myCppObject and this ends only when test time passed. How to solve this?
this->guiLog.log(GUILog::log_info, tr("Execution of script is interrupted by user"), this->logLevelMsgs);
this->connectMyCppObject();//make default connections
}
如何正确断开连接?