From fc4993be1fa7673016b6e5d81134463f163051f6 Mon Sep 17 00:00:00 2001 From: Christoph Schleifenbaum Date: Mon, 25 Aug 2014 12:29:18 +0200 Subject: QListView: Catch stack overflow on mutual scrollbar calculation. Task-number: QTBUG-39902 Change-Id: Ie850371098070e8ce485d5cb122aa89c18d97359 Reviewed-by: Marc Mutz --- .../widgets/itemviews/qlistview/tst_qlistview.cpp | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index b36b5aef8a..bb05db0b15 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -155,6 +155,7 @@ private slots: void spacing(); void testScrollToWithHidden(); void testViewOptions(); + void taskQTBUG_39902_mutualScrollBars(); }; // Testing get/set functions @@ -2355,5 +2356,29 @@ void tst_QListView::testViewOptions() QCOMPARE(options.decorationPosition, QStyleOptionViewItem::Top); } +void tst_QListView::taskQTBUG_39902_mutualScrollBars() +{ + QWidget window; + window.resize(400, 300); + QListView *view = new QListView(&window); + QStandardItemModel model(200, 1); + const QSize itemSize(100, 20); + for (int i = 0; i < model.rowCount(); ++i) + model.setData(model.index(i, 0), itemSize, Qt::SizeHintRole); + view->setModel(&model); + + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + // make sure QListView is done with layouting the items (1/10 sec, like QListView) + QTest::qWait(100); + + model.setRowCount(2); + for (int i = 0; i < model.rowCount(); ++i) + model.setData(model.index(i, 0), itemSize, Qt::SizeHintRole); + view->resize(itemSize.width() + view->frameWidth() * 2, model.rowCount() * itemSize.height() + view->frameWidth() * 2); + // this will end up in a stack overflow, if QTBUG-39902 is not fixed + QTest::qWait(100); +} + QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" -- cgit v1.2.3