--- Vago/trunk/Vago/converter.cpp 2016/09/16 22:51:26 1047 +++ s10k/Vago/converter.cpp 2017/12/30 13:57:32 1093 @@ -1,15 +1,14 @@ #include "converter.h" -Converter::Converter(QString AppDir, Logger *myLogger, QStringList *myData) +Converter::Converter(QString AppDir, QStringList *myData) { this->AppDir=AppDir; - this->myLogger=myLogger; this->myData=myData; } #ifdef Q_OS_WIN -Converter::Converter(QString AppDir, Logger *myLogger, QStringList *myData, QWinTaskbarProgress *win7TaskBarProgress) - : Converter(AppDir, myLogger, myData) +Converter::Converter(QString AppDir, QStringList *myData, QWinTaskbarProgress *win7TaskBarProgress) + : Converter(AppDir, myData) { this->win7TaskBarProgress = win7TaskBarProgress; } @@ -17,14 +16,14 @@ Converter::Converter(QString AppDir, Log void Converter::run() { - this->processHasKilled=false; - this->myProcess = new QProcess(); + this->myProcess = std::make_unique(); QString result = QString(); QString errorMessage = ""; int numErrors=0; - this->myLogger->writeString("Setting working dir to "+this->AppDir+"."); - myProcess->setWorkingDirectory(this->AppDir); // Set working directory (for work with AEI2/Mac OS) + this->myProcess->setWorkingDirectory(this->AppDir); // Set working directory (for work with AEI2/Mac OS) + + LOG_INFO << "Setting OniSplit process working dir to " + this->AppDir + "."; #ifdef Q_OS_WIN if(this->win7TaskBarProgress){ @@ -61,10 +60,11 @@ void Converter::run() nextIndex=commands.indexOf(GlobalVars::OniSplitProcSeparator,currentIndex+1); commandToExec=commands.mid(currentIndex,(nextIndex-currentIndex)); - this->myProcess->start(UtilVago::getOniSplitExeAbsolutePath() + " " + commandToExec); + this->myProcess->start(UtilVago::getOniSplitExecutable() + " " + commandToExec); this->myProcess->waitForFinished(-1); - if(this->processHasKilled){ // If the process has killed there's no need to proceed with reading output or process more commands + // If the process has killed there's no need to proceed with reading output or process more commands + if(this->myProcess == nullptr){ #ifdef Q_OS_WIN if(this->win7TaskBarProgress){ @@ -72,18 +72,18 @@ void Converter::run() } #endif - delete this->myProcess; //delete object and make pointer invalid + this->myProcess.reset(); //delete object and make pointer invalid this->myData->clear(); //clean list emit conversionAborted(); return; } - result=this->myProcess->readAllStandardError(); + result = this->myProcess->readAllStandardError(); if(!result.isEmpty()){ //if(!result.startsWith("Importing",Qt::CaseSensitive) && !result.startsWith("Importing",Qt::CaseSensitive)){ //case sensitive is faster //catch exception - myLogger->writeString("Oni Split Error: \n"+this->myData->at(i)+"\n"+result); + LOG_ERROR << "Oni Split Error: \n" + this->myData->at(i) + "\n" + result; errorMessage=result; numErrors++; } @@ -109,7 +109,7 @@ void Converter::run() } #endif - delete this->myProcess; //delete object and make pointer invalid + this->myProcess.reset(); //delete object and make pointer invalid this->myData->clear(); //clean list //let's cut it a bit, complete error is in log file. @@ -125,7 +125,10 @@ void Converter::run() // Kill the process if requested void Converter::terminateCurrProcess(){ - this->myProcess->kill(); - this->processHasKilled=true; - this->myLogger->writeString("Received signal to kill current OniSplit operation (user requested)."); + if(this->myProcess != nullptr){ + this->myProcess->kill(); + this->myProcess.reset(); + } + + LOG_INFO << "Received signal to kill current OniSplit operation (user requested)."; }