ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/s10k/Vago/xmlprocessor.cpp
Revision: 1035
Committed: Thu Mar 24 22:28:41 2016 UTC (9 years, 6 months ago) by s10k
Content type: text/x-c++src
Original Path: Vago/trunk/Vago/xmlprocessor.cpp
File size: 1455 byte(s)
Log Message:
Vago 9.0b

File Contents

# Content
1 #include "xmlprocessor.h"
2
3 XmlProcessor::XmlProcessor(QString AppDir, Logger *myLogger, QStringList *commands)
4 {
5 this->AppDir=AppDir;
6 this->myLogger=myLogger;
7 this->commands=commands;
8 }
9
10 void XmlProcessor::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 for(int i=0; i<this->commands->size(); i++){
20
21 myProcess->start(Util::getXmlToolsExeName() +" "+this->commands->at(i));
22 myProcess->waitForFinished(-1);
23 result=myProcess->readAllStandardError();
24
25 if(!result.isEmpty()){
26 //catch exception
27 myLogger->writeString("Xml Tools Error: \n"+this->commands->at(i)+"\n"+result);
28 errorMessage=result;
29 numErrors++;
30 }
31
32 }
33
34 delete myProcess; //delete object and make pointer invalid
35 this->commands->clear(); //clean list
36
37 //let's cut it a bit, complete error is in log file.
38 if(errorMessage.size()>600){
39 //limit it at 400 characters (not counting the warning at the begin)
40 errorMessage.remove(299,errorMessage.size()-600);
41 errorMessage.insert(299,"\n \t ... \n");
42 errorMessage.insert(0,"This error was been shortened. \nSee the complete error at Vago log file.\n\n");
43 }
44
45 emit resultConversion(errorMessage,numErrors);
46 }
47