From 8fa07c81f69f534366a2b357c5e3d7b978ecb7e8 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 8 Sep 2017 17:29:24 +0200 Subject: [PATCH] QmlProfiler: Accept animations events with 0 animations There is no reason why we shouldn't. Logically that would be an animation frame without any running animations. The frame would still have a frame rate and we can still tell if it's the GUI or render thread. Furthermore the assert might be triggered by invalid trace data. Change-Id: I58578a941c5d1471dd1b299ed5f489ad160b2904 Reviewed-by: Milian Wolff --- src/plugins/qmlprofiler/qmlprofileranimationsmodel.cpp | 1 - .../qmlprofiler/tests/qmlprofileranimationsmodel_test.cpp | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/plugins/qmlprofiler/qmlprofileranimationsmodel.cpp b/src/plugins/qmlprofiler/qmlprofileranimationsmodel.cpp index 0dca25645da..1c00071ad3e 100644 --- a/src/plugins/qmlprofiler/qmlprofileranimationsmodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofileranimationsmodel.cpp @@ -85,7 +85,6 @@ void QmlProfilerAnimationsModel::loadEvent(const QmlEvent &event, const QmlEvent lastEvent.typeId = event.typeIndex(); lastEvent.framerate = event.number(0); lastEvent.animationcount = event.number(1); - QTC_ASSERT(lastEvent.animationcount > 0, return); m_data.insert(insert(realStartTime, realEndTime - realStartTime, lastThread), lastEvent); diff --git a/src/plugins/qmlprofiler/tests/qmlprofileranimationsmodel_test.cpp b/src/plugins/qmlprofiler/tests/qmlprofileranimationsmodel_test.cpp index 846ff731d68..d5723dd731a 100644 --- a/src/plugins/qmlprofiler/tests/qmlprofileranimationsmodel_test.cpp +++ b/src/plugins/qmlprofiler/tests/qmlprofileranimationsmodel_test.cpp @@ -51,7 +51,7 @@ void QmlProfilerAnimationsModelTest::initTestCase() for (int i = 0; i < 10; ++i) { event.setTimestamp(i); - event.setNumbers({frameRate(i), 20 - i, (i % 2) ? RenderThread : GuiThread}); + event.setNumbers({frameRate(i), 9 - i, (i % 2) ? RenderThread : GuiThread}); manager.addEvent(event); } manager.acquiringDone(); @@ -69,8 +69,8 @@ void QmlProfilerAnimationsModelTest::testAccepted() void QmlProfilerAnimationsModelTest::testRowMaxValue() { QCOMPARE(model.rowMaxValue(0), 0); - QCOMPARE(model.rowMaxValue(1), 20); - QCOMPARE(model.rowMaxValue(2), 19); + QCOMPARE(model.rowMaxValue(1), 9); + QCOMPARE(model.rowMaxValue(2), 8); } void QmlProfilerAnimationsModelTest::testRowNumbers() @@ -133,7 +133,7 @@ void QmlProfilerAnimationsModelTest::testDetails() QCOMPARE(details[QmlProfilerAnimationsModel::tr("Framerate")].toString(), QString::fromLatin1("%1 FPS").arg(frameRate(i))); QCOMPARE(details[QmlProfilerAnimationsModel::tr("Animations")].toString(), - QString::number(20 - i)); + QString::number(9 - i)); QCOMPARE(details[QmlProfilerAnimationsModel::tr("Context")].toString(), i % 2 ? QmlProfilerAnimationsModel::tr("Render Thread") : QmlProfilerAnimationsModel::tr("GUI Thread"));