| 9 |
|
|
| 10 |
|
void Converter::run() |
| 11 |
|
{ |
| 12 |
< |
QProcess *myProcess = new QProcess(); |
| 12 |
> |
this->processHasKilled=false; |
| 13 |
> |
this->myProcess = new QProcess(); |
| 14 |
|
QString result = QString(); |
| 15 |
|
QString errorMessage = ""; |
| 16 |
|
int numErrors=0; |
| 17 |
|
|
| 18 |
< |
myProcess->setWorkingDirectory(this->AppDir); |
| 18 |
> |
myProcess->setWorkingDirectory(this->AppDir); // Set working directory (for work with AEI2/Mac OS) |
| 19 |
|
|
| 20 |
|
if(this->myData->size()!=1){ |
| 21 |
|
emit setupPB(this->myData->size()); |
| 24 |
|
emit setupPB(0); //Intermitent bar, we don't have any estimation when the task is done |
| 25 |
|
} |
| 26 |
|
|
| 26 |
– |
//myProcess->setProcessChannelMode(QProcess::MergedChannels); //we want both stdout and stderr |
| 27 |
– |
|
| 27 |
|
for(int i=0; i<this->myData->size(); i++){ |
| 28 |
|
|
| 29 |
|
QString commands=this->myData->at(i); |
| 35 |
|
nextIndex=commands.indexOf(GlobalVars::OniSplitProcSeparator,currentIndex+1); |
| 36 |
|
|
| 37 |
|
commandToExec=commands.mid(currentIndex,(nextIndex-currentIndex)); |
| 38 |
< |
myProcess->start(GlobalVars::OniSplitExeName+" "+commandToExec); |
| 39 |
< |
myProcess->waitForFinished(-1); |
| 40 |
< |
result=myProcess->readAllStandardError(); |
| 38 |
> |
this->myProcess->start(GlobalVars::OniSplitExeName+" "+commandToExec); |
| 39 |
> |
this->myProcess->waitForFinished(-1); |
| 40 |
> |
|
| 41 |
> |
if(this->processHasKilled){ // If the process has killed there's no need to proceed with reading output or process more commands |
| 42 |
> |
delete this->myProcess; //delete object and make pointer invalid |
| 43 |
> |
this->myData->clear(); //clean list |
| 44 |
> |
emit conversionAborted(); |
| 45 |
> |
return; |
| 46 |
> |
} |
| 47 |
> |
|
| 48 |
> |
result=this->myProcess->readAllStandardError(); |
| 49 |
|
|
| 50 |
|
if(!result.isEmpty()){ //if(!result.startsWith("Importing",Qt::CaseSensitive) && !result.startsWith("Importing",Qt::CaseSensitive)){ //case sensitive is faster |
| 51 |
|
//catch exception |
| 63 |
|
emit taskDone(); |
| 64 |
|
} |
| 65 |
|
|
| 66 |
< |
delete myProcess; //delete object and make pointer invalid |
| 66 |
> |
delete this->myProcess; //delete object and make pointer invalid |
| 67 |
|
this->myData->clear(); //clean list |
| 68 |
|
|
| 69 |
|
//let's cut it a bit, complete error is in log file. |
| 77 |
|
emit resultConversion(errorMessage,numErrors); |
| 78 |
|
} |
| 79 |
|
|
| 80 |
+ |
// Kill the process if requested |
| 81 |
+ |
void Converter::terminateCurrProcess(){ |
| 82 |
+ |
this->myProcess->kill(); |
| 83 |
+ |
this->processHasKilled=true; |
| 84 |
+ |
this->myLogger->writeString("Received signal to kill current OniSplit operation (user requested)."); |
| 85 |
+ |
} |