]> git.cworth.org Git - apitrace/commitdiff
Large chunk of showing the replay errors.
authorZack Rusin <zack@kde.org>
Wed, 20 Apr 2011 03:09:26 +0000 (23:09 -0400)
committerZack Rusin <zack@kde.org>
Wed, 20 Apr 2011 03:09:26 +0000 (23:09 -0400)
gui/mainwindow.cpp
gui/mainwindow.h
gui/retracer.cpp
gui/retracer.h

index e89f9f5aec81daaeb049ab623be0477a94e60ffe..a5fbaccc5eabf6b667f60e59c8f5933858707c90 100644 (file)
@@ -654,6 +654,8 @@ void MainWindow::initConnections()
             this, SLOT(replayError(const QString&)));
     connect(m_retracer, SIGNAL(foundState(const ApiTraceState&)),
             this, SLOT(replayStateFound(const ApiTraceState&)));
+    connect(m_retracer, SIGNAL(retraceErrors(const QList<RetraceError>&)),
+            this, SLOT(slotRetraceErrors(const QList<RetraceError>&)));
 
     connect(m_ui.vertexInterpretButton, SIGNAL(clicked()),
             m_vdataInterpreter, SLOT(interpretData()));
@@ -1010,4 +1012,27 @@ void MainWindow::slotTraceChanged(ApiTraceCall *call)
     }
 }
 
+void MainWindow::slotRetraceErrors(const QList<RetraceError> &errors)
+{
+    m_ui.errorsTreeWidget->clear();
+
+    foreach(RetraceError error, errors) {
+        ApiTraceCall *call = m_trace->callWithIndex(error.callIndex);
+        if (!call)
+            continue;
+        call->setError(error.message);
+
+        QTreeWidgetItem *item =
+            new QTreeWidgetItem(m_ui.errorsTreeWidget);
+        item->setData(0, Qt::DisplayRole, error.callIndex);
+        item->setData(0, Qt::UserRole, QVariant::fromValue(call));
+        QString type = error.type;
+        type[0] = type[0].toUpper();
+        item->setData(1, Qt::DisplayRole, type);
+        item->setData(2, Qt::DisplayRole, error.message);
+    }
+
+    m_ui.errorsDock->setVisible(!errors.isEmpty());
+}
+
 #include "mainwindow.moc"
index a08ead25b5c6675fc0da2ec8f3010db8d755c085..400f7a31504dd9b79a7b2d3bfabc62be7c8664c4 100644 (file)
@@ -19,6 +19,7 @@ class JumpWidget;
 class QModelIndex;
 class QProgressBar;
 class QUrl;
+class RetraceError;
 class Retracer;
 class SearchWidget;
 class ShadersSourceWidget;
@@ -66,6 +67,7 @@ private slots:
     void slotGoFrameStart();
     void slotGoFrameEnd();
     void slotTraceChanged(ApiTraceCall *call);
+    void slotRetraceErrors(const QList<RetraceError> &errors);
 
 private:
     void initObjects();
index f28f479b9e3a4b0af9db4d6a9665f51fd8661dbf..027cf5f40652d5da7d54696c84499c5715eb315f 100644 (file)
@@ -100,6 +100,8 @@ void Retracer::run()
             this, SIGNAL(error(const QString&)));
     connect(retrace, SIGNAL(foundState(const ApiTraceState&)),
             this, SIGNAL(foundState(const ApiTraceState&)));
+    connect(retrace, SIGNAL(retraceErrors(const QList<RetraceError>&)),
+            this, SIGNAL(retraceErrors(const QList<RetraceError>&)));
 
     retrace->start();
 
@@ -141,10 +143,11 @@ 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) {
@@ -157,6 +160,21 @@ void RetraceProcess::replayFinished()
         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 +188,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)),
index 617861e6cdc4e314c752410238f040f178aced08..1b5a4bd04313ed0ed3406eb42588397583bdc60f 100644 (file)
@@ -9,6 +9,12 @@ namespace QJson {
     class Parser;
 }
 
+struct RetraceError {
+    int callIndex;
+    QString type;
+    QString message;
+};
+
 /* internal class used by the retracer to run
  * in the thread */
 class RetraceProcess : public QObject
@@ -43,6 +49,7 @@ signals:
     void finished(const QString &output);
     void error(const QString &msg);
     void foundState(const ApiTraceState &state);
+    void retraceErrors(const QList<RetraceError> &errors);
 
 private slots:
     void replayFinished();
@@ -84,6 +91,7 @@ signals:
     void finished(const QString &output);
     void foundState(const ApiTraceState &state);
     void error(const QString &msg);
+    void retraceErrors(const QList<RetraceError> &errors);
 
 protected:
     virtual void run();