on xenial help sign in
LVWPH: Remove processEvents() call from updatePolish()

It causes some reentrancy issues and in some times you end up in polishItems() with items that have been deleted because you called processEvents() This means i need a small tweak in itemGeometryChanged to not reposition items if we are inside a setContentHeight call and two small tweaks to tests since now things happen in a different order and numbers are different (though equivalent) Fixes: 1297240

commit94098fef18ae766d1b59665612e721f672a009ae authorAlbert Astals <albert.astals@canonical.com> dateTue 1 Apr 2014, 22:55 (13 years ago) parentb9341058a6773a
3 files changed+4−10
plugins/DashViews/listviewwithpageheader.cpp+1−6 tests/plugins/DashViews/listviewwithpageheadertest.cpp−1 tests/plugins/DashViews/listviewwithpageheadertestsection.cpp+3−3
plugins/DashViews/listviewwithpageheader.cpp+1−6
@@ -1097,7 +1097,7 @@ void ListViewWithPageHeader::itemGeometryChanged(QQuickItem * /*item*/, const QR
10971097{
10981098 const qreal heightDiff = newGeometry.height() - oldGeometry.height();
10991099 if (heightDiff != 0) {
1100− if (oldGeometry.y() + oldGeometry.height() + m_clipItem->y() <= contentY() && !m_visibleItems.isEmpty()) {
1100+ if (!m_inContentHeightKeepHeaderShown && oldGeometry.y() + oldGeometry.height() + m_clipItem->y() <= contentY() && !m_visibleItems.isEmpty()) {
11011101 ListItem *firstItem = m_visibleItems.first();
11021102 firstItem->setY(firstItem->y() - heightDiff);
11031103 adjustMinYExtent();
@@ -1293,11 +1293,6 @@ void ListViewWithPageHeader::updatePolish()
12931293 refill();
12941294
12951295 if (m_contentHeightDirty) {
1296− // We need to make sure all bindings have updated otherwise
1297− // we may end up with bindings updating when we call setContentHeight
1298− // and then everything gets out of sync, i.e. testHeaderPositionBug1240118
1299− QCoreApplication::instance()->processEvents();
1300−
13011296 qreal contentHeight;
13021297 if (m_visibleItems.isEmpty()) {
13031298 contentHeight = m_headerItem ? m_headerItem->height() : 0;
tests/plugins/DashViews/listviewwithpageheadertest.cpp−1
@@ -1855,7 +1855,6 @@ private Q_SLOTS:
18551855 scrollToBottom();
18561856 lvwph->showHeader();
18571857 QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1858− QTest::qWait(100); // Make sure stuff is stable
18591858 QMetaObject::invokeMethod(model, "insertItem", Q_ARG(QVariant, 0), Q_ARG(QVariant, 100));
18601859 model->setProperty(3, "size", 10);
18611860 model->setProperty(4, "size", 10);
tests/plugins/DashViews/listviewwithpageheadertestsection.cpp+3−3
@@ -1680,12 +1680,11 @@ private Q_SLOTS:
16801680 verifyItem(18, 700, 50., false, QString(), true);
16811681 verifyItem(19, 750, 50., false, QString(), true);
16821682 verifyItem(20, 800, 50., false, QString(), true);
1683− QCOMPARE(lvwph->m_minYExtent, 5 * 1510./21. + 660 - 1970 + 50);
1684− QCOMPARE(lvwph->m_clipItem->y(), 1970.);
1683+ QCOMPARE(lvwph->m_clipItem->y(), lvwph->contentY());
1684+ QCOMPARE(lvwph->m_minYExtent, 5 * 1510./21. + 660 - lvwph->contentY() + 50);
16851685 QCOMPARE(lvwph->m_clipItem->clip(), false);
16861686 QCOMPARE(lvwph->m_headerItem->y(), 0.);
16871687 QCOMPARE(lvwph->m_headerItem->height(), 50.);
1688− QCOMPARE(lvwph->contentY(), 1970.);
16891688 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
16901689 }
16911690
@@ -2108,6 +2107,7 @@ private Q_SLOTS:
21082107 QVERIFY(QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
21092108
21102109 QTest::qWait(1);
2110+ QCoreApplication::instance()->processEvents();
21112111
21122112 changeContentY(-15);
21132113