From 0df8cc2e0287203d05233b22a90a70db3ba2557c Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 9 Apr 2015 15:34:09 +0200 Subject: [PATCH] Timeline: Clear excess row heights when reducing the number of rows Otherwise, if you increase the number of rows again later you get surprising results. Change-Id: I3ec809820716368849415f9dcdb1ec9208844353 Reviewed-by: Joerg Bornemann --- src/libs/timeline/timelinemodel.cpp | 2 ++ tests/auto/timeline/timelinemodel/tst_timelinemodel.cpp | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libs/timeline/timelinemodel.cpp b/src/libs/timeline/timelinemodel.cpp index 099492114c2..2b1d7d50cc1 100644 --- a/src/libs/timeline/timelinemodel.cpp +++ b/src/libs/timeline/timelinemodel.cpp @@ -136,6 +136,8 @@ void TimelineModel::setExpandedRowCount(int rows) { Q_D(TimelineModel); if (d->expandedRowCount != rows) { + if (d->rowOffsets.length() > rows) + d->rowOffsets.resize(rows); d->expandedRowCount = rows; emit expandedRowCountChanged(); if (d->expanded) diff --git a/tests/auto/timeline/timelinemodel/tst_timelinemodel.cpp b/tests/auto/timeline/timelinemodel/tst_timelinemodel.cpp index 7080d11bbaa..078bcbb04eb 100644 --- a/tests/auto/timeline/timelinemodel/tst_timelinemodel.cpp +++ b/tests/auto/timeline/timelinemodel/tst_timelinemodel.cpp @@ -232,8 +232,12 @@ void tst_TimelineModel::height() QCOMPARE(dummy.height(), 2 * DefaultRowHeight); dummy.setExpanded(true); QCOMPARE(dummy.height(), 3 * DefaultRowHeight); - dummy.setExpandedRowHeight(0, 80); + dummy.setExpandedRowHeight(1, 80); QCOMPARE(dummy.height(), 2 * DefaultRowHeight + 80); + dummy.clear(); + dummy.loadData(); + dummy.setExpanded(true); + QCOMPARE(dummy.rowHeight(1), DefaultRowHeight); // Make sure the row height gets reset. } void tst_TimelineModel::count()