ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/s10k/Vago/converter.cpp
(Generate patch)

Comparing Vago/trunk/Vago/converter.cpp (file contents):
Revision 771 by s10k, Sun Mar 31 19:02:16 2013 UTC vs.
Revision 1031 by iritscen, Sun Mar 13 16:11:45 2016 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)