diff --git a/Decoder.cpp b/Decoder.cpp index 891501a..f863edc 100644 --- a/Decoder.cpp +++ b/Decoder.cpp @@ -50,7 +50,9 @@ Worker* Decoder::createWorker(){ connect(&m_thread, &QThread::finished, worker, &QObject::deleteLater); connect(this, &Decoder::startWorker, worker, &Worker::start); 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; } @@ -88,6 +90,18 @@ void Decoder::processQuit(){ 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 //////////////// //////////////////////////////////////// @@ -123,32 +137,15 @@ void Worker::start(QString path, QStringList args){ }); connect(proc, static_cast (&QProcess::error), - [this, proc] (QProcess::ProcessError e) { - emit error(); + [this, proc] (QProcess::ProcessError errorCode) { + emit error(int(errorCode)); }); connect(proc, static_cast (&QProcess::finished), [this, proc] (int exitCode, QProcess::ExitStatus status) { - emit finished(); + emit finished(exitCode, int(status)); }); - - auto watcher = new QTimer(this); - - connect(proc, static_cast (&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 ()}; env.insert ("OMP_STACKSIZE", "4M"); proc->setProcessEnvironment (env); diff --git a/Decoder.h b/Decoder.h index 6dd2756..a267e90 100644 --- a/Decoder.h +++ b/Decoder.h @@ -26,8 +26,8 @@ private: signals: void ready(QByteArray t); - void error(); - void finished(); + void error(int errorCode); + void finished(int exitCode, int statusCode); private: QScopedPointer m_proc; @@ -56,11 +56,16 @@ public slots: void processReady(QByteArray t); void processQuit(); + void processError(int errorCode); + void processFinished(int exitCode, int statusCode); + signals: void startWorker(QString path, QStringList args); void quitWorker(); void ready(QByteArray t); + void error(int errorCode); + void finished(int exitCode, int statusCode); private: QPointer m_worker;