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.
s10k/Vago/converter.cpp (file contents), Revision 1092 by s10k, Sat Dec 30 13:43:28 2017 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 + #ifdef Q_OS_WIN
11 + Converter::Converter(QString AppDir, Logger *myLogger, QStringList *myData, QWinTaskbarProgress *win7TaskBarProgress)
12 +    : Converter(AppDir, myLogger, myData)
13 + {
14 +    this->win7TaskBarProgress = win7TaskBarProgress;
15 + }
16 + #endif
17 +
18   void Converter::run()
19   {
20 <    QProcess *myProcess = new QProcess();
20 >    this->processHasKilled=false;
21 >    this->myProcess = new QProcess();
22      QString result = QString();
23      QString errorMessage = "";
24      int numErrors=0;
25  
26 +    this->myLogger->writeString("Setting OniSplit process working dir to "+this->AppDir+".");
27 +    myProcess->setWorkingDirectory(this->AppDir); // Set working directory (for work with AEI2/Mac OS)
28 +
29 + #ifdef Q_OS_WIN
30 +    if(this->win7TaskBarProgress){
31 +        this->win7TaskBarProgress->reset();
32 +        this->win7TaskBarProgress->show();
33 +    }
34 + #endif
35 +
36      if(this->myData->size()!=1){
37 + #ifdef Q_OS_WIN
38 +        if(this->win7TaskBarProgress){
39 +            this->win7TaskBarProgress->setRange(0,this->myData->size());
40 +        }
41 + #endif
42          emit setupPB(this->myData->size());
43      }
44      else{
45 + #ifdef Q_OS_WIN
46 +        if(this->win7TaskBarProgress){
47 +            this->win7TaskBarProgress->setRange(0,0);
48 +        }
49 + #endif
50          emit setupPB(0); //Intermitent bar, we don't have any estimation when the task is done
51      }
52  
23    //myProcess->setProcessChannelMode(QProcess::MergedChannels); //we want both stdout and stderr
24
53      for(int i=0; i<this->myData->size(); i++){
54  
55          QString commands=this->myData->at(i);
# Line 33 | Line 61 | void Converter::run()
61              nextIndex=commands.indexOf(GlobalVars::OniSplitProcSeparator,currentIndex+1);
62  
63              commandToExec=commands.mid(currentIndex,(nextIndex-currentIndex));
64 <            myProcess->start(GlobalVars::OniSplitExeName+" "+commandToExec);
65 <            myProcess->waitForFinished(-1);
66 <            result=myProcess->readAllStandardError();
64 >            this->myProcess->start(UtilVago::getOniSplitExecutable() + " " + commandToExec);
65 >            this->myProcess->waitForFinished(-1);
66 >
67 >            if(this->processHasKilled){ // If the process has killed there's no need to proceed with reading output or process more commands
68 >
69 > #ifdef Q_OS_WIN
70 >                if(this->win7TaskBarProgress){
71 >                    this->win7TaskBarProgress->hide();
72 >                }
73 > #endif
74 >
75 >                delete this->myProcess; //delete object and make pointer invalid
76 >                this->myData->clear(); //clean list
77 >                emit conversionAborted();
78 >
79 >                return;
80 >            }
81 >
82 >            result=this->myProcess->readAllStandardError();
83  
84              if(!result.isEmpty()){ //if(!result.startsWith("Importing",Qt::CaseSensitive) && !result.startsWith("Importing",Qt::CaseSensitive)){ //case sensitive is faster
85                  //catch exception
# Line 50 | Line 94 | void Converter::run()
94              currentIndex=nextIndex+1; //update currentIndex +1 for start after the separator
95          }
96  
97 + #ifdef Q_OS_WIN
98 +        if(this->win7TaskBarProgress){
99 +            this->win7TaskBarProgress->setValue(win7TaskBarProgress->value()+1);
100 +        }
101 + #endif
102 +
103          emit taskDone();
104      }
105  
106 <    delete myProcess; //delete object and make pointer invalid
106 > #ifdef Q_OS_WIN
107 >    if(this->win7TaskBarProgress){
108 >        this->win7TaskBarProgress->hide();
109 >    }
110 > #endif
111 >
112 >    delete this->myProcess; //delete object and make pointer invalid
113      this->myData->clear(); //clean list
114  
115      //let's cut it a bit, complete error is in log file.
# Line 67 | Line 123 | void Converter::run()
123      emit resultConversion(errorMessage,numErrors);
124   }
125  
126 + // Kill the process if requested
127 + void Converter::terminateCurrProcess(){
128 +    this->myProcess->kill();
129 +    this->processHasKilled=true;
130 +    this->myLogger->writeString("Received signal to kill current OniSplit operation (user requested).");
131 + }

Diff Legend

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