on xenial help sign in
Remove processEvents() call from ListViewWithPageHeader::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 needs 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)

commitf12d80634b5dba306a53144828254764f52dab58 authorAlbert Astals <albert.astals@canonical.com> dateFri 28 Mar 2014, 17:56 (13 years ago) parent183a834
3 files changed+6−11
plugins/DashViews/listviewwithpageheader.cpp+1−6 tests/plugins/DashViews/listviewwithpageheadertest.cpp−1 tests/plugins/DashViews/listviewwithpageheadertestsection.cpp+5−4
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+5−4
@@ -1680,12 +1680,12 @@ 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_minYExtent, 5 * 1510./21. + 660 - 1670 + 50);
1684+ QCOMPARE(lvwph->m_clipItem->y(), 1670.);
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.);
1688+ QCOMPARE(lvwph->contentY(), 1670.);
16891689 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
16901690 }
16911691
@@ -2108,7 +2108,8 @@ private Q_SLOTS:
21082108 QVERIFY(QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
21092109
21102110 QTest::qWait(1);
2111−
2111+ QCoreApplication::instance()->processEvents();
2112+
21122113 changeContentY(-15);
21132114
21142115 QTRY_COMPARE(lvwph->m_visibleItems.count(), 1);