summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar@trolltech.com>2009-11-09 06:58:56 (GMT)
committerGunnar Sletta <gunnar@trolltech.com>2009-11-09 09:14:08 (GMT)
commit9c6e3590da6c49d055d452b08de0e51b0b77f1c4 (patch)
tree97c61f690a67d7dd1b25b45be933c53575f710e4
parentabe04b845ea19110dbbc06ba443fe1bf6a29ee92 (diff)
downloadQt-9c6e3590da6c49d055d452b08de0e51b0b77f1c4.zip
Qt-9c6e3590da6c49d055d452b08de0e51b0b77f1c4.tar.gz
Qt-9c6e3590da6c49d055d452b08de0e51b0b77f1c4.tar.bz2
Fixed up qttracereplay and trace graphicsystem a bit.
- Added "qttrace" to binary file, making it possible to do a sanity verification of the input file in qttracereplay - Sanity check input binary file, both for existance and for content in qttracereplay - Console app on windows and mac - Added helpful output for -h and --help command line options Reviewed-by: Samuel
-rw-r--r--src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp1
-rw-r--r--tools/qttracereplay/main.cpp38
-rw-r--r--tools/qttracereplay/qttracereplay.pro2
3 files changed, 31 insertions, 10 deletions
diff --git a/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp b/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp
index 8756ecb..fb6f5ea 100644
--- a/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp
+++ b/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp
@@ -82,6 +82,7 @@ QTraceWindowSurface::~QTraceWindowSurface()
QFile outputFile(QString(QLatin1String("qtgraphics-%0.trace")).arg(winId));
if (outputFile.open(QIODevice::WriteOnly)) {
QDataStream out(&outputFile);
+ out.writeBytes("qttrace", 7);
out << *buffer << updates;
}
delete buffer;
diff --git a/tools/qttracereplay/main.cpp b/tools/qttracereplay/main.cpp
index 1d21a21..7261082 100644
--- a/tools/qttracereplay/main.cpp
+++ b/tools/qttracereplay/main.cpp
@@ -56,7 +56,7 @@ public:
public slots:
void updateRect();
-private:
+public:
QList<QRegion> updates;
QPaintBuffer buffer;
@@ -70,7 +70,8 @@ private:
void ReplayWidget::updateRect()
{
- update(updates.at(currentFrame));
+ if (!updates.isEmpty())
+ update(updates.at(currentFrame));
}
void ReplayWidget::paintEvent(QPaintEvent *)
@@ -138,12 +139,25 @@ ReplayWidget::ReplayWidget(const QString &filename_)
QFile file(filename);
QRect bounds;
- if (file.open(QIODevice::ReadOnly)) {
- QDataStream in(&file);
- in >> buffer >> updates;
+ if (!file.open(QIODevice::ReadOnly)) {
+ printf("Failed to load input file '%s'\n", qPrintable(filename_));
+ return;
+ }
+
+ QDataStream in(&file);
+
+ char *data;
+ uint size;
+ in.readBytes(data, size);
+ bool isTraceFile = size == 7 && qstrncmp(data, "qttrace", 7) == 0;
+ delete [] data;
+ if (!isTraceFile) {
+ printf("File '%s' is not a trace file\n", qPrintable(filename_));
+ return;
}
- qDebug() << "Read paint buffer with" << buffer.numFrames() << "frames";
+ in >> buffer >> updates;
+ printf("Read paint buffer with %d frames\n", buffer.numFrames());
resize(buffer.boundingRect().size().toSize());
@@ -157,14 +171,18 @@ int main(int argc, char **argv)
{
QApplication app(argc, argv);
- if (argc <= 1) {
- printf("Usage: %s filename\n", argv[0]);
+ if (argc <= 1 || qstrcmp(argv[1], "-h") == 0 || qstrcmp(argv[1], "--help") == 0) {
+ printf("Replays a tracefile generated with '-graphicssystem trace'\n");
+ printf("Usage:\n > %s [traceFile]\n", argv[0]);
return 1;
}
ReplayWidget *widget = new ReplayWidget(argv[1]);
- widget->show();
- return app.exec();
+ if (!widget->updates.isEmpty()) {
+ widget->show();
+ return app.exec();
+ }
+
}
#include "main.moc"
diff --git a/tools/qttracereplay/qttracereplay.pro b/tools/qttracereplay/qttracereplay.pro
index 766ed04..cc5b98d 100644
--- a/tools/qttracereplay/qttracereplay.pro
+++ b/tools/qttracereplay/qttracereplay.pro
@@ -11,3 +11,5 @@ SOURCES += main.cpp
target.path=$$[QT_INSTALL_BINS]
INSTALLS += target
+
+CONFIG += console