| 1 |  | #include "converter.h" | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 2 |  |  | 
 
 
 
 
 
 
 
 
 
 
 | 3 | < | Converter::Converter(QString AppDir, Logger *myLogger, QStringList *myData) | 
 
 
 
 
 
 
 
 
 | 3 | > | Converter::Converter(QString AppDir, QStringList *myData) | 
 
 
 
 
 
 
 
 
 
 
 | 4 |  | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 5 |  | this->AppDir=AppDir; | 
 
 
 
 
 
 
 
 
 | 6 | – | this->myLogger=myLogger; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 6 |  | this->myData=myData; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 7 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 8 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 9 |  | #ifdef Q_OS_WIN | 
 
 
 
 
 
 
 
 
 
 
 | 10 | < | Converter::Converter(QString AppDir, Logger *myLogger, QStringList *myData, QWinTaskbarProgress *win7TaskBarProgress) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 11 | < | : Converter(AppDir, myLogger, myData) | 
 
 
 
 
 
 
 
 
 | 10 | > | Converter::Converter(QString AppDir, QStringList *myData, QWinTaskbarProgress *win7TaskBarProgress) | 
 
 
 
 
 | 11 | > | : Converter(AppDir, myData) | 
 
 
 
 
 
 
 
 
 
 
 | 12 |  | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 13 |  | this->win7TaskBarProgress = win7TaskBarProgress; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 14 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 16 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 17 |  | void Converter::run() | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 18 |  | { | 
 
 
 
 
 
 
 
 
 
 
 | 19 | < | this->processHasKilled=false; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 21 | < | this->myProcess = new QProcess(); | 
 
 
 
 
 
 
 
 
 | 19 | > | this->myProcess = std::make_unique<QProcess>(); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 20 |  | QString result = QString(); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 21 |  | QString errorMessage = ""; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 22 |  | int numErrors=0; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 23 |  |  | 
 
 
 
 
 
 
 
 
 
 
 | 24 | < | this->myLogger->writeString("Setting OniSplit process working dir to "+this->AppDir+"."); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 25 | < | myProcess->setWorkingDirectory(this->AppDir); // Set working directory (for work with AEI2/Mac OS) | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 24 | > | this->myProcess->setWorkingDirectory(this->AppDir); // Set working directory (for work with AEI2/Mac OS) | 
 
 
 
 
 | 25 | > |  | 
 
 
 
 
 | 26 | > | LOG_INFO << "Setting OniSplit process working dir to " + this->AppDir + "."; | 
 
 
 
 
 
 
 
 
 
 
 | 27 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 28 |  | #ifdef Q_OS_WIN | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 29 |  | if(this->win7TaskBarProgress){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 63 |  | this->myProcess->start(UtilVago::getOniSplitExecutable() + " " + commandToExec); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 64 |  | this->myProcess->waitForFinished(-1); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 65 |  |  | 
 
 
 
 
 
 
 
 
 
 
 | 66 | < | if(this->processHasKilled){ // If the process has killed there's no need to proceed with reading output or process more commands | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 66 | > | // If the process has killed there's no need to proceed with reading output or process more commands | 
 
 
 
 
 | 67 | > | if(this->myProcess == nullptr){ | 
 
 
 
 
 
 
 
 
 
 
 | 68 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 69 |  | #ifdef Q_OS_WIN | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 70 |  | if(this->win7TaskBarProgress){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 72 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 73 |  | #endif | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 74 |  |  | 
 
 
 
 
 
 
 
 
 
 
 | 75 | < | delete this->myProcess; //delete object and make pointer invalid | 
 
 
 
 
 
 
 
 
 | 75 | > | this->myProcess.reset(); //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(); | 
 
 
 
 
 
 
 
 
 | 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 | 
 
 
 
 
 
 
 
 
 
 
 | 86 | < | myLogger->writeString("Oni Split Error: \n"+this->myData->at(i)+"\n"+result); | 
 
 
 
 
 
 
 
 
 | 86 | > | LOG_ERROR << "Oni Split Error: \n" + this->myData->at(i) + "\n" + result; | 
 
 
 
 
 
 
 
 
 
 
 | 87 |  | errorMessage=result; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 88 |  | numErrors++; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 89 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 109 |  | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 110 |  | #endif | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 111 |  |  | 
 
 
 
 
 
 
 
 
 
 
 | 112 | < | delete this->myProcess; //delete object and make pointer invalid | 
 
 
 
 
 
 
 
 
 | 112 | > | this->myProcess.reset(); //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. | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 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)."); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 128 | > | if(this->myProcess != nullptr){ | 
 
 
 
 
 | 129 | > | this->myProcess->kill(); | 
 
 
 
 
 | 130 | > | this->myProcess.reset(); | 
 
 
 
 
 | 131 | > | } | 
 
 
 
 
 | 132 | > |  | 
 
 
 
 
 | 133 | > | LOG_INFO << "Received signal to kill current OniSplit operation (user requested)."; | 
 
 
 
 
 
 
 
 
 
 
 | 134 |  | } |