[PATCH 3/6] Notify retracer of missing thumbnails to capture
Dan McCabe
zen3d.linux at gmail.com
Fri Jun 1 13:40:04 PDT 2012
Now that the trace knows what thumbnails are needed, that information
needs to be communicated to the retracer to actually capture them.
The trace is modified to iterate through the missing thumbnails. For
each of these thumbnail indices, the trace calls a callback to notify
it of the thumbnail.
I don't really like my solution to this but I couldn't figure out a
better one. What I wanted to do was have the trace hand out an iterator
along the lines of what Java or C# do, but I couldn't figure out how
to create one. If the reviewers of this code have a suggestion, I'm all
ears.
The main window provides the callback and acts as an intermediate to the
retracer. The callback receives the missing index and passes it to the
retracer, which then adds the index to the collection of missing thumbnail
indices it is gathering.
---
gui/apitrace.cpp | 9 +++++++++
gui/apitrace.h | 4 ++++
gui/mainwindow.cpp | 12 ++++++++++++
gui/mainwindow.h | 1 +
gui/retracer.cpp | 12 ++++++++++++
gui/retracer.h | 5 +++++
6 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/gui/apitrace.cpp b/gui/apitrace.cpp
index 2de4563..0a2965e 100644
--- a/gui/apitrace.cpp
+++ b/gui/apitrace.cpp
@@ -527,4 +527,13 @@ void ApiTrace::resetMissingThumbnails()
m_missingThumbnails.clear();
}
+void ApiTrace::iterateMissingThumbnails(void *object, ThumbnailCallback cb)
+{
+ //qDebug() << QLatin1String("debug: count of missing thumbnail list") << m_missingThumbnails.count();
+ foreach (int thumbnailIndex, m_missingThumbnails) {
+ //qDebug() << QLatin1String("debug: iterate missing thumbnail list") << thumbnailIndex;
+ (*cb)(object, thumbnailIndex);
+ }
+}
+
#include "apitrace.moc"
diff --git a/gui/apitrace.h b/gui/apitrace.h
index a6cfa1c..a01e761 100644
--- a/gui/apitrace.h
+++ b/gui/apitrace.h
@@ -12,6 +12,8 @@ class TraceLoader;
class SaverThread;
class QThread;
+typedef void (*ThumbnailCallback)(void *object, int thumbnailIdx);
+
class ApiTrace : public QObject
{
Q_OBJECT
@@ -83,6 +85,8 @@ public:
bool isMissingThumbnails() const;
void resetMissingThumbnails();
+ void iterateMissingThumbnails(void *object, ThumbnailCallback cb);
+
public slots:
void setFileName(const QString &name);
void save();
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index 50f7d91..9eaa8b0 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -301,6 +301,11 @@ void MainWindow::replayTrace(bool dumpState, bool dumpThumbnails)
}
m_retracer->setCaptureAtCallNumber(index);
}
+ if (m_trace->isMissingThumbnails()) {
+ m_retracer->resetThumbnailsToCapture();
+ m_trace->iterateMissingThumbnails(this, this->thumbnailCallback);
+ m_trace->resetMissingThumbnails();
+ }
m_retracer->start();
m_ui.actionStop->setEnabled(true);
@@ -1345,4 +1350,11 @@ void MainWindow::slotJumpToResult(ApiTraceCall *call)
}
}
+void MainWindow::thumbnailCallback(void *object, int thumbnailIdx)
+{
+ //qDebug() << QLatin1String("debug: transfer from trace to retracer thumbnail index: ") << thumbnailIdx;
+ MainWindow *mySelf = (MainWindow *) object;
+ mySelf->m_retracer->addThumbnailToCapture(thumbnailIdx);
+}
+
#include "mainwindow.moc"
diff --git a/gui/mainwindow.h b/gui/mainwindow.h
index 1346b86..021bf10 100644
--- a/gui/mainwindow.h
+++ b/gui/mainwindow.h
@@ -107,6 +107,7 @@ private:
ApiTraceFrame *currentFrame() const;
ApiTraceCall *currentCall() const;
+ static void thumbnailCallback(void *object, int thumbnailIdx);
private:
Ui_MainWindow m_ui;
diff --git a/gui/retracer.cpp b/gui/retracer.cpp
index 69dca6c..0c6de6e 100644
--- a/gui/retracer.cpp
+++ b/gui/retracer.cpp
@@ -212,6 +212,18 @@ void Retracer::setCaptureThumbnails(bool enable)
m_captureThumbnails = enable;
}
+void Retracer::addThumbnailToCapture(qlonglong num)
+{
+ if (!m_thumbnailsToCapture.contains(num)) {
+ m_thumbnailsToCapture.append(num);
+ }
+}
+
+void Retracer::resetThumbnailsToCapture()
+{
+ m_thumbnailsToCapture.clear();
+}
+
/**
* Starting point for the retracing thread.
diff --git a/gui/retracer.h b/gui/retracer.h
index d6da7ac..57abdc8 100644
--- a/gui/retracer.h
+++ b/gui/retracer.h
@@ -35,6 +35,9 @@ public:
bool captureThumbnails() const;
void setCaptureThumbnails(bool enable);
+ void addThumbnailToCapture(qlonglong num);
+ void resetThumbnailsToCapture();
+
signals:
void finished(const QString &output);
void foundState(ApiTraceState *state);
@@ -55,6 +58,8 @@ private:
qlonglong m_captureCall;
QProcessEnvironment m_processEnvironment;
+
+ QList<qlonglong> m_thumbnailsToCapture;
};
#endif
--
1.7.9.1
More information about the apitrace
mailing list