| 7 |
|
this->myData=myData; |
| 8 |
|
} |
| 9 |
|
|
| 10 |
+ |
#ifdef Q_OS_WIN |
| 11 |
+ |
Converter::Converter(QString AppDir, Logger *myLogger, QStringList *myData, QWinTaskbarProgress *win7TaskBarProgress) |
| 12 |
+ |
: Converter(AppDir, myLogger, myData) |
| 13 |
+ |
{ |
| 14 |
+ |
this->win7TaskBarProgress = win7TaskBarProgress; |
| 15 |
+ |
} |
| 16 |
+ |
#endif |
| 17 |
+ |
|
| 18 |
|
void Converter::run() |
| 19 |
|
{ |
| 20 |
< |
QProcess *myProcess = new QProcess(); |
| 20 |
> |
this->processHasKilled=false; |
| 21 |
> |
this->myProcess = new QProcess(); |
| 22 |
|
QString result = QString(); |
| 23 |
|
QString errorMessage = ""; |
| 24 |
|
int numErrors=0; |
| 25 |
|
|
| 26 |
< |
myProcess->setWorkingDirectory(this->AppDir); |
| 26 |
> |
this->myLogger->writeString("Setting working dir to "+this->AppDir+"."); |
| 27 |
> |
myProcess->setWorkingDirectory(this->AppDir); // Set working directory (for work with AEI2/Mac OS) |
| 28 |
> |
|
| 29 |
> |
#ifdef Q_OS_WIN |
| 30 |
> |
if(this->win7TaskBarProgress){ |
| 31 |
> |
this->win7TaskBarProgress->reset(); |
| 32 |
> |
this->win7TaskBarProgress->show(); |
| 33 |
> |
} |
| 34 |
> |
#endif |
| 35 |
|
|
| 36 |
|
if(this->myData->size()!=1){ |
| 37 |
+ |
#ifdef Q_OS_WIN |
| 38 |
+ |
if(this->win7TaskBarProgress){ |
| 39 |
+ |
this->win7TaskBarProgress->setRange(0,this->myData->size()); |
| 40 |
+ |
} |
| 41 |
+ |
#endif |
| 42 |
|
emit setupPB(this->myData->size()); |
| 43 |
|
} |
| 44 |
|
else{ |
| 45 |
+ |
#ifdef Q_OS_WIN |
| 46 |
+ |
if(this->win7TaskBarProgress){ |
| 47 |
+ |
this->win7TaskBarProgress->setRange(0,0); |
| 48 |
+ |
} |
| 49 |
+ |
#endif |
| 50 |
|
emit setupPB(0); //Intermitent bar, we don't have any estimation when the task is done |
| 51 |
|
} |
| 52 |
|
|
| 26 |
– |
//myProcess->setProcessChannelMode(QProcess::MergedChannels); //we want both stdout and stderr |
| 27 |
– |
|
| 53 |
|
for(int i=0; i<this->myData->size(); i++){ |
| 54 |
|
|
| 55 |
|
QString commands=this->myData->at(i); |
| 61 |
|
nextIndex=commands.indexOf(GlobalVars::OniSplitProcSeparator,currentIndex+1); |
| 62 |
|
|
| 63 |
|
commandToExec=commands.mid(currentIndex,(nextIndex-currentIndex)); |
| 64 |
< |
myProcess->start(GlobalVars::OniSplitExeName+" "+commandToExec); |
| 65 |
< |
myProcess->waitForFinished(-1); |
| 66 |
< |
result=myProcess->readAllStandardError(); |
| 64 |
> |
this->myProcess->start(UtilVago::getOniSplitExecutable() + " " + commandToExec); |
| 65 |
> |
this->myProcess->waitForFinished(-1); |
| 66 |
> |
|
| 67 |
> |
if(this->processHasKilled){ // If the process has killed there's no need to proceed with reading output or process more commands |
| 68 |
> |
|
| 69 |
> |
#ifdef Q_OS_WIN |
| 70 |
> |
if(this->win7TaskBarProgress){ |
| 71 |
> |
this->win7TaskBarProgress->hide(); |
| 72 |
> |
} |
| 73 |
> |
#endif |
| 74 |
> |
|
| 75 |
> |
delete this->myProcess; //delete object and make pointer invalid |
| 76 |
> |
this->myData->clear(); //clean list |
| 77 |
> |
emit conversionAborted(); |
| 78 |
> |
|
| 79 |
> |
return; |
| 80 |
> |
} |
| 81 |
> |
|
| 82 |
> |
result=this->myProcess->readAllStandardError(); |
| 83 |
|
|
| 84 |
|
if(!result.isEmpty()){ //if(!result.startsWith("Importing",Qt::CaseSensitive) && !result.startsWith("Importing",Qt::CaseSensitive)){ //case sensitive is faster |
| 85 |
|
//catch exception |
| 94 |
|
currentIndex=nextIndex+1; //update currentIndex +1 for start after the separator |
| 95 |
|
} |
| 96 |
|
|
| 97 |
+ |
#ifdef Q_OS_WIN |
| 98 |
+ |
if(this->win7TaskBarProgress){ |
| 99 |
+ |
this->win7TaskBarProgress->setValue(win7TaskBarProgress->value()+1); |
| 100 |
+ |
} |
| 101 |
+ |
#endif |
| 102 |
+ |
|
| 103 |
|
emit taskDone(); |
| 104 |
|
} |
| 105 |
|
|
| 106 |
< |
delete myProcess; //delete object and make pointer invalid |
| 106 |
> |
#ifdef Q_OS_WIN |
| 107 |
> |
if(this->win7TaskBarProgress){ |
| 108 |
> |
this->win7TaskBarProgress->hide(); |
| 109 |
> |
} |
| 110 |
> |
#endif |
| 111 |
> |
|
| 112 |
> |
delete this->myProcess; //delete object and make pointer invalid |
| 113 |
|
this->myData->clear(); //clean list |
| 114 |
|
|
| 115 |
|
//let's cut it a bit, complete error is in log file. |
| 123 |
|
emit resultConversion(errorMessage,numErrors); |
| 124 |
|
} |
| 125 |
|
|
| 126 |
+ |
// Kill the process if requested |
| 127 |
+ |
void Converter::terminateCurrProcess(){ |
| 128 |
+ |
this->myProcess->kill(); |
| 129 |
+ |
this->processHasKilled=true; |
| 130 |
+ |
this->myLogger->writeString("Received signal to kill current OniSplit operation (user requested)."); |
| 131 |
+ |
} |