--- Vago/trunk/Vago/converter.cpp 2014/01/08 11:32:55 897 +++ s10k/Vago/converter.cpp 2017/12/30 13:57:32 1093 @@ -1,26 +1,51 @@ #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, QStringList *myData, QWinTaskbarProgress *win7TaskBarProgress) + : Converter(AppDir, myData) +{ + this->win7TaskBarProgress = win7TaskBarProgress; +} +#endif + void Converter::run() { - this->processHasKilled=false; - this->myProcess = new QProcess(); + this->myProcess = std::make_unique(); QString result = QString(); QString errorMessage = ""; int numErrors=0; - 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){ + this->win7TaskBarProgress->reset(); + this->win7TaskBarProgress->show(); + } +#endif if(this->myData->size()!=1){ +#ifdef Q_OS_WIN + if(this->win7TaskBarProgress){ + this->win7TaskBarProgress->setRange(0,this->myData->size()); + } +#endif emit setupPB(this->myData->size()); } else{ +#ifdef Q_OS_WIN + if(this->win7TaskBarProgress){ + this->win7TaskBarProgress->setRange(0,0); + } +#endif emit setupPB(0); //Intermitent bar, we don't have any estimation when the task is done } @@ -35,21 +60,30 @@ void Converter::run() nextIndex=commands.indexOf(GlobalVars::OniSplitProcSeparator,currentIndex+1); commandToExec=commands.mid(currentIndex,(nextIndex-currentIndex)); - this->myProcess->start(GlobalVars::OniSplitExeName+" "+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 - delete this->myProcess; //delete object and make pointer invalid + // 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){ + this->win7TaskBarProgress->hide(); + } +#endif + + 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++; } @@ -60,10 +94,22 @@ void Converter::run() currentIndex=nextIndex+1; //update currentIndex +1 for start after the separator } +#ifdef Q_OS_WIN + if(this->win7TaskBarProgress){ + this->win7TaskBarProgress->setValue(win7TaskBarProgress->value()+1); + } +#endif + emit taskDone(); } - delete this->myProcess; //delete object and make pointer invalid +#ifdef Q_OS_WIN + if(this->win7TaskBarProgress){ + this->win7TaskBarProgress->hide(); + } +#endif + + 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. @@ -79,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)."; }