summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp2
-rw-r--r--tests/auto/qlistview/tst_qlistview.cpp28
2 files changed, 29 insertions, 1 deletions
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index 55b3a03..975decc 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -1380,7 +1380,7 @@ bool QAbstractItemView::event(QEvent *event)
d->executePostedLayout(); //make sure we set the layout properly
break;
case QEvent::Show:
- {
+ if (d->delayedPendingLayout) {
d->executePostedLayout(); //make sure we set the layout properly
const QModelIndex current = currentIndex();
if (current.isValid() && (d->state == QAbstractItemView::EditingState || d->autoScroll))
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp
index 2e7f412..c372475 100644
--- a/tests/auto/qlistview/tst_qlistview.cpp
+++ b/tests/auto/qlistview/tst_qlistview.cpp
@@ -105,6 +105,7 @@ private slots:
void task203585_selectAll();
void task228566_infiniteRelayout();
void task248430_crashWith0SizedItem();
+ void task250446_scrollChanged();
};
// Testing get/set functions
@@ -1528,5 +1529,32 @@ void tst_QListView::task248430_crashWith0SizedItem()
QTest::qWait(100);
}
+void tst_QListView::task250446_scrollChanged()
+{
+ QStandardItemModel model(200, 1);
+ QListView view;
+ view.setModel(&model);
+ QModelIndex index = model.index(0, 0);
+ QVERIFY(index.isValid());
+ view.setCurrentIndex(index);
+ view.show();
+ QTest::qWait(100);
+ const int scrollValue = view.verticalScrollBar()->maximum();
+ view.verticalScrollBar()->setValue(scrollValue);
+ QCOMPARE(view.verticalScrollBar()->value(), scrollValue);
+ QCOMPARE(view.currentIndex(), index);
+
+ view.showMinimized();
+ QTest::qWait(100);
+ QCOMPARE(view.verticalScrollBar()->value(), scrollValue);
+ QCOMPARE(view.currentIndex(), index);
+
+ view.showNormal();
+ QTest::qWait(100);
+ QCOMPARE(view.verticalScrollBar()->value(), scrollValue);
+ QCOMPARE(view.currentIndex(), index);
+}
+
+
QTEST_MAIN(tst_QListView)
#include "tst_qlistview.moc"