Esempio n. 1
0
int Loader::load(QString program, QString workpath, QStringList args)
{
    this->program = program;
    this->workpath = workpath;

    stop();
    connect(process, SIGNAL(readyReadStandardOutput()),this,SLOT(procReadyRead()));
    connect(process, SIGNAL(started()),this,SLOT(procStarted()));
    connect(process, SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(procFinished(int,QProcess::ExitStatus)));
    connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(procError(QProcess::ProcessError)));

    process->setProcessChannelMode(QProcess::MergedChannels);
    process->setWorkingDirectory(this->workpath);
#if 0
    this->port = "";
    for(int n = 0; n < args.length(); n++) {
        QString arg = args.at(n);
        if(arg.contains("-p", Qt::CaseInsensitive)){
            this->port = args.at(n+1);
            break;
        }
    }
#endif
    this->setPlainText("");
    setReady(false);
    setDisableIO(false);
    process->start(this->program,args);

    while(running == false)
        QApplication::processEvents();

    return process->exitCode();
}
int BuildManager::runProcess(const QString & programName, const QStringList & programArgs)
{
    QStringList args;
    QString program = QDir::toNativeSeparators(programName);
    for (int i = 0; i < programArgs.size(); ++i)
    {
        args.append(QDir::toNativeSeparators(programArgs.at(i)));
    }
    qDebug() << program << args;

    proc = new QProcess;

    proc->setProcessChannelMode(QProcess::MergedChannels);

    procDone = false;

    connect(proc, SIGNAL(readyReadStandardOutput()),this,SLOT(procReadyRead()));
    connect(proc, SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(compilerFinished(int,QProcess::ExitStatus)));

    proc->start(QDir::toNativeSeparators(program),args);

    QTextCharFormat tf = consoleEdit->currentCharFormat();
    tf.setForeground(Qt::black);
    consoleEdit->setCurrentCharFormat(tf);

    if(!proc->waitForStarted())
    {
        QMessageBox::critical(this, tr("Error"),
                              tr("Could not start \"%1.\"\nPlease check Preferences.")
                              .arg(program));
        return 1;
    }

    while(!procDone)
    {
        QApplication::processEvents();
        QThread::msleep(5);
    }

    if(proc->exitStatus() == QProcess::CrashExit)
    {
        QMessageBox::critical(this, tr("Error"),
                              tr("%1 crashed.")
                              .arg(program));
        return 1;
    }

    if(proc->exitCode())
        return 1;

    disconnect(proc);
    delete proc;
    return 0;
}
Esempio n. 3
0
int Loader::reload(QString port)
{
    QStringList args;

    if(this->program.length() == 0) {
        QSettings settings(publisherKey, ASideGuiKey,this);
        QVariant incv = settings.value(includesKey);
        if(incv.canConvert(QVariant::String)) {
            QString s = incv.toString();
            s = QDir::fromNativeSeparators(s);
            this->program = s + "propeller-load";
#if defined(Q_WS_WIN32)
            this->program+=".exe";
#endif
        }
    }

    stop();
    connect(process, SIGNAL(readyReadStandardOutput()),this,SLOT(procReadyRead()));
    connect(process, SIGNAL(started()),this,SLOT(procStarted()));
    connect(process, SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(procFinished(int,QProcess::ExitStatus)));
    connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(procError(QProcess::ProcessError)));

    process->setProcessChannelMode(QProcess::MergedChannels);
    process->setWorkingDirectory(this->workpath);

    if(port.length() > 0) {
        args.append("-p");
        args.append(port);
        args.append("-t");
    }

    setReady(false);
    setDisableIO(false);
    process->start(this->program,args);

    while(running == false)
        QApplication::processEvents();

    return process->exitCode();
}