Example #1
0
Thread::Thread( QObject * const parent )
    : QThread( parent )
{
    // we need a class that receives signals from other threads and emits a signal in response
    m_shutDownHelper = new QSignalMapper;
    m_shutDownHelper->setMapping( this, 0 );
    connect( this, SIGNAL(started()), this, SLOT(setReadyStatus()), Qt::DirectConnection );
    connect( this, SIGNAL(aboutToStop()), m_shutDownHelper, SLOT(map()));
}
Example #2
0
void Run::run()
{    
    while (vm->hasMoreInstructions()) {
        if (mustStop()) {
            break;
        }
        vm->evaluateNextInstruction();        
        if (vm->error().length()>0 && !stoppingFlag_) {
            int lineNo = vm->effectiveLineNo();
            std::pair<quint32,quint32> colNo =
                    vm->effectiveColumn();
            emit lineChanged(lineNo, colNo.first, colNo.second);
            emit error(QString::fromStdWString(vm->error()));
            break;
        }
    }
    if (vm->error().length() == 0 && !stoppingFlag_ &&
            vm->entryPoint() == KumirVM::EP_Testing)
    {
        qApp->setProperty("returnCode", vm->returnCode());
    }
//    bool wasError = vm->error().length()>0;
    // Unclosed files is an error only if program reached end
    bool unclosedFilesIsNotError = stoppingFlag_ || vm->hasMoreInstructions();
    // Must close all files if program reached end or user terminated
    bool programFinished = stoppingFlag_ || !vm->hasMoreInstructions() || vm->error().length();
//    __check_for_unclosed_files__st_funct(unclosedFilesIsNotError, closeUnclosedFiles);
//    vm->updateStFunctError();
//    if (!wasError && vm->error().length()>0) {
//        emit lineChanged(vm->effectiveLineNo());
//        emit error(QString::fromStdWString(vm->error()));
//    }
    if (programFinished)
        Kumir::finalizeStandardLibrary();
    emit aboutToStop();
}
Example #3
0
// puts a command to stop processing in the event queue of worker thread
void Thread::stop()
{
    emit aboutToStop();
}