summaryrefslogtreecommitdiffstats
path: root/tools/qttracereplay/main.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2009-11-17 16:43:48 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-11-17 16:43:48 (GMT)
commitcb5e66d1d43c0cf452aff0e437a2ea9011c6b659 (patch)
tree0aa5378385a5492e4fe55c7b7003cd32f83bf6b6 /tools/qttracereplay/main.cpp
parent798ff84b2bd26da5ba2d01bf44e4a4d40dfcacac (diff)
parent334b2a93d461ae9a8b258fff1971fb775b13bb68 (diff)
downloadQt-cb5e66d1d43c0cf452aff0e437a2ea9011c6b659.zip
Qt-cb5e66d1d43c0cf452aff0e437a2ea9011c6b659.tar.gz
Qt-cb5e66d1d43c0cf452aff0e437a2ea9011c6b659.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'tools/qttracereplay/main.cpp')
-rw-r--r--tools/qttracereplay/main.cpp38
1 files changed, 28 insertions, 10 deletions
diff --git a/tools/qttracereplay/main.cpp b/tools/qttracereplay/main.cpp
index e62cf2c..4760c43 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,8 +171,9 @@ 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;
}
@@ -169,8 +184,11 @@ int main(int argc, char **argv)
}
ReplayWidget *widget = new ReplayWidget(argv[1]);
- widget->show();
- return app.exec();
+ if (!widget->updates.isEmpty()) {
+ widget->show();
+ return app.exec();
+ }
+
}
#include "main.moc"