]> git.cworth.org Git - apitrace/blobdiff - gui/retracer.cpp
Reduce the size of ApiTraceCall, ApiTraceEvent and ApiTraceFrame
[apitrace] / gui / retracer.cpp
index f28f479b9e3a4b0af9db4d6a9665f51fd8661dbf..500d859aa3f6d73011acc0bbaabd38a58ed19287 100644 (file)
@@ -9,7 +9,7 @@
 
 Retracer::Retracer(QObject *parent)
     : QThread(parent),
-      m_benchmarking(true),
+      m_benchmarking(false),
       m_doubleBuffered(true),
       m_captureState(false),
       m_captureCall(0)
@@ -98,8 +98,10 @@ void Retracer::run()
             this, SIGNAL(finished(const QString&)));
     connect(retrace, SIGNAL(error(const QString&)),
             this, SIGNAL(error(const QString&)));
-    connect(retrace, SIGNAL(foundState(const ApiTraceState&)),
-            this, SIGNAL(foundState(const ApiTraceState&)));
+    connect(retrace, SIGNAL(foundState(ApiTraceState*)),
+            this, SIGNAL(foundState(ApiTraceState*)));
+    connect(retrace, SIGNAL(retraceErrors(const QList<RetraceError>&)),
+            this, SIGNAL(retraceErrors(const QList<RetraceError>&)));
 
     retrace->start();
 
@@ -120,6 +122,8 @@ void RetraceProcess::start()
 
     if (m_doubleBuffered) {
         arguments << QLatin1String("-db");
+    } else {
+        arguments << QLatin1String("-sb");
     }
 
     if (m_captureState) {
@@ -141,22 +145,38 @@ void RetraceProcess::replayFinished()
 {
     QByteArray output = m_process->readAllStandardOutput();
     QString msg;
+    QString errStr = m_process->readAllStandardError();
 
 #if 0
     qDebug()<<"Process finished = ";
-    qDebug()<<"\terr = "<<m_process->readAllStandardError();
+    qDebug()<<"\terr = "<<errStr;
     qDebug()<<"\tout = "<<output;
 #endif
     if (m_captureState) {
         bool ok = false;
         QVariantMap parsedJson = m_jsonParser->parse(output, &ok).toMap();
-        ApiTraceState state(parsedJson);
+        ApiTraceState *state = new ApiTraceState(parsedJson);
         emit foundState(state);
         msg = tr("State fetched.");
     } else {
         msg = QString::fromUtf8(output);
     }
 
+    QStringList errorLines = errStr.split('\n');
+    QList<RetraceError> errors;
+    QRegExp regexp("(^\\d+): +(\\b\\w+\\b): (.+$)");
+    foreach(QString line, errorLines) {
+        if (regexp.indexIn(line) != -1) {
+            RetraceError error;
+            error.callIndex = regexp.cap(1).toInt();
+            error.type = regexp.cap(2);
+            error.message = regexp.cap(3);
+            errors.append(error);
+        }
+    }
+    if (!errors.isEmpty()) {
+        emit retraceErrors(errors);
+    }
     emit finished(msg);
 }
 
@@ -170,13 +190,15 @@ void RetraceProcess::replayError(QProcess::ProcessError err)
         tr("Couldn't execute the replay file '%1'").arg(m_fileName));
 }
 
-
+Q_DECLARE_METATYPE(QList<RetraceError>);
 RetraceProcess::RetraceProcess(QObject *parent)
     : QObject(parent)
 {
     m_process = new QProcess(this);
     m_jsonParser = new QJson::Parser();
 
+    qRegisterMetaType<QList<RetraceError> >();
+
     connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)),
             this, SLOT(replayFinished()));
     connect(m_process, SIGNAL(error(QProcess::ProcessError)),