Merge lp:~aacid/unity8/lvwph_culling_off_by_one into lp:unity8

Proposed by Albert Astals Cid
Status: Merged
Approved by: MichaƂ Sawicz
Approved revision: 165
Merged at revision: 166
Proposed branch: lp:~aacid/unity8/lvwph_culling_off_by_one
Merge into: lp:unity8
Diff against target: 82 lines (+41/-2)
3 files modified
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp (+2/-2)
tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp (+19/-0)
tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp (+20/-0)
To merge this branch: bzr merge lp:~aacid/unity8/lvwph_culling_off_by_one
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Gerry Boland (community) Approve
Review via email: mp+178689@code.launchpad.net

Commit message

Fix off by one in the culling condition

If you are on 0 and your height is 1 and viewport starts at 1 you have to be culled since you are not visible

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/ListViewWithPageHeader/listviewwithpageheader.cpp'
2--- plugins/ListViewWithPageHeader/listviewwithpageheader.cpp 2013-08-02 08:52:54 +0000
3+++ plugins/ListViewWithPageHeader/listviewwithpageheader.cpp 2013-08-06 08:29:29 +0000
4@@ -734,7 +734,7 @@
5 releaseItem(listItem);
6 listItem = nullptr;
7 } else {
8- listItem->setCulled(listItem->y() + listItem->height() + m_clipItem->y() < contentY() || listItem->y() + m_clipItem->y() >= contentY() + height());
9+ listItem->setCulled(listItem->y() + listItem->height() + m_clipItem->y() <= contentY() || listItem->y() + m_clipItem->y() >= contentY() + height());
10 if (m_visibleItems.isEmpty()) {
11 m_visibleItems << listItem;
12 } else {
13@@ -1040,7 +1040,7 @@
14 int firstReallyVisibleItem = -1;
15 int modelIndex = m_firstVisibleIndex;
16 Q_FOREACH(ListItem *item, m_visibleItems) {
17- const bool cull = pos + item->height() < visibleFrom || pos >= visibleTo;
18+ const bool cull = pos + item->height() <= visibleFrom || pos >= visibleTo;
19 item->setCulled(cull);
20 item->setY(pos);
21 if (!cull && firstReallyVisibleItem == -1) {
22
23=== modified file 'tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp'
24--- tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp 2013-07-29 11:31:31 +0000
25+++ tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp 2013-08-06 08:29:29 +0000
26@@ -1390,6 +1390,25 @@
27 lvwph->showHeader();
28 }
29
30+ void testCullOnBottomEdge()
31+ {
32+ changeContentY(200);
33+
34+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
35+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
36+ verifyItem(0, -150., 150., true);
37+ verifyItem(1, 0., 200., false);
38+ verifyItem(2, 200., 350., false);
39+ verifyItem(3, 550., 350., true);
40+ QCOMPARE(lvwph->m_minYExtent, 0.);
41+ QCOMPARE(lvwph->m_clipItem->y(), 200.);
42+ QCOMPARE(lvwph->m_clipItem->clip(), false);
43+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
44+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
45+ QCOMPARE(lvwph->contentY(), 200.);
46+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
47+ }
48+
49 private:
50 QQuickView *view;
51 ListViewWithPageHeader *lvwph;
52
53=== modified file 'tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp'
54--- tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp 2013-08-02 08:52:54 +0000
55+++ tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp 2013-08-06 08:29:29 +0000
56@@ -1691,6 +1691,26 @@
57 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
58 }
59
60+ void testCullOnBottomEdge()
61+ {
62+ changeContentY(240);
63+
64+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
65+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
66+ verifyItem(0, -190., 190., true, "Agressive", true);
67+ verifyItem(1, 0., 240., false, "Regular", false);
68+ verifyItem(2, 240., 390., false, "Mild", false);
69+ verifyItem(3, 630., 390., true, "Bold", true);
70+ QCOMPARE(lvwph->m_minYExtent, 0.);
71+ QCOMPARE(lvwph->m_clipItem->y(), 240.);
72+ QCOMPARE(lvwph->m_clipItem->clip(), false);
73+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
74+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
75+ QCOMPARE(lvwph->contentY(), 240.);
76+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
77+ QVERIFY(QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
78+ }
79+
80 private:
81 QQuickView *view;
82 ListViewWithPageHeader *lvwph;

Subscribers

People subscribed via source and target branches