on xenial help sign in
Don't do stuff if our parent context is gone
c15bc46Albert Astals
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+17
@@ -479,6 +479,12 @@ void ListViewWithPageHeader::componentComplete()
479
479
480void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
480void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
481{
481{
482+ // Check we are not being taken down and don't paint anything
483+ // TODO Check if we still need this in 5.2
484+ // For reproduction just inifnite loop testDash or testDashContent
485+ if (!QQmlEngine::contextForObject(this)->parentContext())
486+ return;
487+
482 QQuickFlickable::viewportMoved(orient);
488 QQuickFlickable::viewportMoved(orient);
483// qDebug() << "ListViewWithPageHeader::viewportMoved" << contentY();
489// qDebug() << "ListViewWithPageHeader::viewportMoved" << contentY();
484 qreal diff = m_previousContentY - contentY();
490 qreal diff = m_previousContentY - contentY();
@@ -855,6 +861,11 @@ void ListViewWithPageHeader::itemCreated(int modelIndex, QObject *object)
855 }
861 }
856#endif
862#endif
857// qDebug() << "ListViewWithPageHeader::itemCreated" << modelIndex << item;
863// qDebug() << "ListViewWithPageHeader::itemCreated" << modelIndex << item;
864+ // Check we are not being taken down and don't paint anything
865+ // TODO Check if we still need this in 5.2
866+ // For reproduction just inifnite loop testDash or testDashContent
867+ if (!QQmlEngine::contextForObject(this)->parentContext())
868+ return;
858
869
859 item->setParentItem(m_clipItem);
870 item->setParentItem(m_clipItem);
860 QQmlContext *context = QQmlEngine::contextForObject(item)->parentContext();
871 QQmlContext *context = QQmlEngine::contextForObject(item)->parentContext();
@@ -1235,6 +1246,12 @@ void ListViewWithPageHeader::layout()
1235
1246
1236void ListViewWithPageHeader::updatePolish()
1247void ListViewWithPageHeader::updatePolish()
1237{
1248{
1249+ // Check we are not being taken down and don't paint anything
1250+ // TODO Check if we still need this in 5.2
1251+ // For reproduction just inifnite loop testDash or testDashContent
1252+ if (!QQmlEngine::contextForObject(this)->parentContext())
1253+ return;
1254+
1238 Q_FOREACH(ListItem *item, m_itemsToRelease)
1255 Q_FOREACH(ListItem *item, m_itemsToRelease)
1239 reallyReleaseItem(item);
1256 reallyReleaseItem(item);
1240 m_itemsToRelease.clear();
1257 m_itemsToRelease.clear();
tests/qmltests/Dash/tst_Dash.qml+5−1
@@ -102,11 +102,15 @@ Item {
102 console.log("Not testing " + data.tag + ": not visible");
102 console.log("Not testing " + data.tag + ": not visible");
103 return;
103 return;
104 }
104 }
105+ var dashContentList = findChild(dash, "dashContentList");
106+
105 dash.showScopeOnLoaded = data.tag
107 dash.showScopeOnLoaded = data.tag
106 scopes.clear();
108 scopes.clear();
109+ tryCompare(dashContentList, "count", 0);
107 scopes.load();
110 scopes.load();
111+ tryCompare(scopes, "loaded", true);
112+ tryCompare(dashContentList, "count", 4);
108
113
109− var dashContentList = findChild(dash, "dashContentList");
110 verify(dashContentList != undefined);
114 verify(dashContentList != undefined);
111 tryCompare(dashContentList, "currentIndex", data.visualIndex);
115 tryCompare(dashContentList, "currentIndex", data.visualIndex);
112 }
116 }
tests/qmltests/Dash/tst_DashContent.qml+14−12
@@ -124,13 +124,6 @@ Item {
124
124
125 var dashContentList = findChild(dashContent, "dashContentList");
125 var dashContentList = findChild(dashContent, "dashContentList");
126 verify(dashContentList != undefined);
126 verify(dashContentList != undefined);
127− // TODO For Qt 5.2 remove this wait
128− // and the tryCompare and see if it still crashes when
129− // looping the test
130− wait(1000);
131− if (dashContentList.currentItem !== null) {
132− tryCompare(dashContentList.currentItem, "moving", false);
133− }
134 scopesModel.clear();
127 scopesModel.clear();
135 // wait for dash to empty scopes.
128 // wait for dash to empty scopes.
136 tryCompare(dashContentList, "count", 0);
129 tryCompare(dashContentList, "count", 0);
@@ -248,18 +241,27 @@ Item {
248 tryCompare(scopesModel.get(2), "isActive", data.active2);
241 tryCompare(scopesModel.get(2), "isActive", data.active2);
249 }
242 }
250
243
251− function test_hswipe_disabled_vswipe() {
244+ function checkFlickMovingAndNotInteractive()
245+ {
252 var dashContentList = findChild(dashContent, "dashContentList");
246 var dashContentList = findChild(dashContent, "dashContentList");
253
247
254− tryCompare(dashContentList, "interactive", true);
248+ if (dashContentList.currentItem.moving && !dashContentList.interactive)
249+ return true;
255
250
256 var startX = dashContentList.width/2;
251 var startX = dashContentList.width/2;
257 var startY = dashContentList.height/2;
252 var startY = dashContentList.height/2;
258− touchFlick(dashContentList, startX, startY, startX, startY - units.gu(80));
253+ touchFlick(dashContentList, startX, startY, startX, startY - units.gu(40));
254+
255+ return dashContentList.currentItem.moving && !dashContentList.interactive;
256+ }
259
257
260− tryCompare(dashContentList.currentItem, "moving", true);
261
258
259+ function test_hswipe_disabled_vswipe() {
260+ var dashContentList = findChild(dashContent, "dashContentList");
261+
262− compare(dashContentList.interactive, false);
262+ tryCompare(dashContentList, "interactive", true);
263+
264+ tryCompareFunction(checkFlickMovingAndNotInteractive, true);
263 }
265 }
264 }
266 }
265}
267}