ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/s10k/Vago/converter.cpp
Revision: 815
Committed: Sat Apr 13 13:44:29 2013 UTC (12 years, 6 months ago) by s10k
Content type: text/x-c++src
Original Path: Vago/trunk/Vago/converter.cpp
File size: 2471 byte(s)
Log Message:
Vago: Some more app dir mac fixes

File Contents

# Content
1 #include "converter.h"
2
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();
13 QString result = QString();
14 QString errorMessage = "";
15 int numErrors=0;
16
17 myProcess->setWorkingDirectory(this->AppDir);
18
19 if(this->myData->size()!=1){
20 emit setupPB(this->myData->size());
21 }
22 else{
23 emit setupPB(0); //Intermitent bar, we don't have any estimation when the task is done
24 }
25
26 //myProcess->setProcessChannelMode(QProcess::MergedChannels); //we want both stdout and stderr
27
28 for(int i=0; i<this->myData->size(); i++){
29
30 QString commands=this->myData->at(i);
31 QString commandToExec;
32
33 int currentIndex=0, nextIndex=0;
34
35 while(true){
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();
42
43 if(!result.isEmpty()){ //if(!result.startsWith("Importing",Qt::CaseSensitive) && !result.startsWith("Importing",Qt::CaseSensitive)){ //case sensitive is faster
44 //catch exception
45 myLogger->writeString("Oni Split Error: \n"+this->myData->at(i)+"\n"+result);
46 errorMessage=result;
47 numErrors++;
48 }
49
50 if(nextIndex==-1){ //we got to the end, stop proccessing commands
51 break;
52 }
53 currentIndex=nextIndex+1; //update currentIndex +1 for start after the separator
54 }
55
56 emit taskDone();
57 }
58
59 delete myProcess; //delete object and make pointer invalid
60 this->myData->clear(); //clean list
61
62 //let's cut it a bit, complete error is in log file.
63 if(errorMessage.size()>600){
64 //limit it at 400 characters (not counting the warning at the begin)
65 errorMessage.remove(299,errorMessage.size()-600);
66 errorMessage.insert(299,"\n \t ... \n");
67 errorMessage.insert(0,"This error was been shortened. \nSee the complete error at Vago log file.\n\n");
68 }
69
70 emit resultConversion(errorMessage,numErrors);
71 }
72