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 815 by s10k, Sat Apr 13 13:44:29 2013 UTC vs.
Revision 897 by s10k, Wed Jan 8 11:32:55 2014 UTC

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

Diff Legend

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