Added error and finished signals to the decoder process
This commit is contained in:
parent
670faf3397
commit
cb7f84d952
39
Decoder.cpp
39
Decoder.cpp
@ -50,7 +50,9 @@ Worker* Decoder::createWorker(){
|
|||||||
connect(&m_thread, &QThread::finished, worker, &QObject::deleteLater);
|
connect(&m_thread, &QThread::finished, worker, &QObject::deleteLater);
|
||||||
connect(this, &Decoder::startWorker, worker, &Worker::start);
|
connect(this, &Decoder::startWorker, worker, &Worker::start);
|
||||||
connect(this, &Decoder::quitWorker, worker, &Worker::quit);
|
connect(this, &Decoder::quitWorker, worker, &Worker::quit);
|
||||||
connect(worker, &Worker::ready, this, &Decoder::ready);
|
connect(worker, &Worker::ready, this, &Decoder::processReady);
|
||||||
|
connect(worker, &Worker::error, this, &Decoder::processError);
|
||||||
|
connect(worker, &Worker::finished, this, &Decoder::processFinished);
|
||||||
return worker;
|
return worker;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,6 +90,18 @@ void Decoder::processQuit(){
|
|||||||
emit quitWorker();
|
emit quitWorker();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
void Decoder::processError(int errorCode){
|
||||||
|
if(JS8_DEBUG_DECODE) qDebug() << "decoder process error" << errorCode;
|
||||||
|
emit error(errorCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
void Decoder::processFinished(int exitCode, int statusCode){
|
||||||
|
if(JS8_DEBUG_DECODE) qDebug() << "decoder process finished" << exitCode << statusCode;
|
||||||
|
emit finished(exitCode, statusCode);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
//////////////// WORKER ////////////////
|
//////////////// WORKER ////////////////
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
@ -123,32 +137,15 @@ void Worker::start(QString path, QStringList args){
|
|||||||
});
|
});
|
||||||
|
|
||||||
connect(proc, static_cast<void (QProcess::*) (QProcess::ProcessError)> (&QProcess::error),
|
connect(proc, static_cast<void (QProcess::*) (QProcess::ProcessError)> (&QProcess::error),
|
||||||
[this, proc] (QProcess::ProcessError e) {
|
[this, proc] (QProcess::ProcessError errorCode) {
|
||||||
emit error();
|
emit error(int(errorCode));
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(proc, static_cast<void (QProcess::*) (int, QProcess::ExitStatus)> (&QProcess::finished),
|
connect(proc, static_cast<void (QProcess::*) (int, QProcess::ExitStatus)> (&QProcess::finished),
|
||||||
[this, proc] (int exitCode, QProcess::ExitStatus status) {
|
[this, proc] (int exitCode, QProcess::ExitStatus status) {
|
||||||
emit finished();
|
emit finished(exitCode, int(status));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
auto watcher = new QTimer(this);
|
|
||||||
|
|
||||||
connect(proc, static_cast<void (QProcess::*) (int, QProcess::ExitStatus)> (&QProcess::finished),
|
|
||||||
[this, watcher] (int /*exitCode*/, QProcess::ExitStatus /*status*/) {
|
|
||||||
watcher->stop();
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(watcher, &QTimer::timeout,
|
|
||||||
[this, proc](){
|
|
||||||
if(JS8_DEBUG_DECODE) qDebug() << "decode process" << proc->state() << "can readline?" << proc->canReadLine();
|
|
||||||
});
|
|
||||||
|
|
||||||
watcher->setInterval(500);
|
|
||||||
watcher->start();
|
|
||||||
|
|
||||||
|
|
||||||
QProcessEnvironment env {QProcessEnvironment::systemEnvironment ()};
|
QProcessEnvironment env {QProcessEnvironment::systemEnvironment ()};
|
||||||
env.insert ("OMP_STACKSIZE", "4M");
|
env.insert ("OMP_STACKSIZE", "4M");
|
||||||
proc->setProcessEnvironment (env);
|
proc->setProcessEnvironment (env);
|
||||||
|
@ -26,8 +26,8 @@ private:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void ready(QByteArray t);
|
void ready(QByteArray t);
|
||||||
void error();
|
void error(int errorCode);
|
||||||
void finished();
|
void finished(int exitCode, int statusCode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<QProcess> m_proc;
|
QScopedPointer<QProcess> m_proc;
|
||||||
@ -56,11 +56,16 @@ public slots:
|
|||||||
void processReady(QByteArray t);
|
void processReady(QByteArray t);
|
||||||
void processQuit();
|
void processQuit();
|
||||||
|
|
||||||
|
void processError(int errorCode);
|
||||||
|
void processFinished(int exitCode, int statusCode);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void startWorker(QString path, QStringList args);
|
void startWorker(QString path, QStringList args);
|
||||||
void quitWorker();
|
void quitWorker();
|
||||||
|
|
||||||
void ready(QByteArray t);
|
void ready(QByteArray t);
|
||||||
|
void error(int errorCode);
|
||||||
|
void finished(int exitCode, int statusCode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<Worker> m_worker;
|
QPointer<Worker> m_worker;
|
||||||
|
Loading…
Reference in New Issue
Block a user