summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflickable.cpp98
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslistview.cpp6
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsloader.cpp89
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsloader_p.h1
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsloader_p_p.h5
-rw-r--r--tests/auto/declarative/listview/data/listview-sections.qml59
-rw-r--r--tests/auto/declarative/listview/tst_listview.cpp94
-rw-r--r--tests/auto/declarative/qfxloader/tst_qfxloader.cpp13
8 files changed, 272 insertions, 93 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
index c7332f9..b030495 100644
--- a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
@@ -185,17 +185,17 @@ void QmlGraphicsFlickablePrivate::flickX(qreal velocity)
{
Q_Q(QmlGraphicsFlickable);
qreal maxDistance = -1;
- if (qAbs(velocity) < minimumFlickVelocity) // Minimum velocity to avoid annoyingly slow flicks.
- velocity = velocity < 0 ? -minimumFlickVelocity : minimumFlickVelocity;
// -ve velocity means list is moving up
if (velocity > 0) {
- if (_moveX.value() < q->minXExtent())
- maxDistance = qAbs(q->minXExtent() -_moveX.value() + (overShoot?30:0));
- flickTargetX = q->minXExtent();
+ const qreal minX = q->minXExtent();
+ if (_moveX.value() < minX)
+ maxDistance = qAbs(minX -_moveX.value() + (overShoot?30:0));
+ flickTargetX = minX;
} else {
- if (_moveX.value() > q->maxXExtent())
- maxDistance = qAbs(q->maxXExtent() - _moveX.value()) + (overShoot?30:0);
- flickTargetX = q->maxXExtent();
+ const qreal maxX = q->maxXExtent();
+ if (_moveX.value() > maxX)
+ maxDistance = qAbs(maxX - _moveX.value()) + (overShoot?30:0);
+ flickTargetX = maxX;
}
if (maxDistance > 0) {
qreal v = velocity;
@@ -225,13 +225,15 @@ void QmlGraphicsFlickablePrivate::flickY(qreal velocity)
qreal maxDistance = -1;
// -ve velocity means list is moving up
if (velocity > 0) {
- if (_moveY.value() < q->minYExtent())
- maxDistance = qAbs(q->minYExtent() -_moveY.value() + (overShoot?30:0));
- flickTargetY = q->minYExtent();
+ const qreal minY = q->minYExtent();
+ if (_moveY.value() < minY)
+ maxDistance = qAbs(minY -_moveY.value() + (overShoot?30:0));
+ flickTargetY = minY;
} else {
- if (_moveY.value() > q->maxYExtent())
- maxDistance = qAbs(q->maxYExtent() - _moveY.value()) + (overShoot?30:0);
- flickTargetY = q->maxYExtent();
+ const qreal maxY = q->maxYExtent();
+ if (_moveY.value() > maxY)
+ maxDistance = qAbs(maxY - _moveY.value()) + (overShoot?30:0);
+ flickTargetY = maxY;
}
if (maxDistance > 0) {
qreal v = velocity;
@@ -261,8 +263,6 @@ void QmlGraphicsFlickablePrivate::fixupX()
if (!q->xflick() || _moveX.timeLine())
return;
- vTime = timeline.time();
-
if (_moveX.value() > q->minXExtent() || (q->maxXExtent() > q->minXExtent())) {
timeline.reset(_moveX);
if (_moveX.value() != q->minXExtent())
@@ -275,6 +275,8 @@ void QmlGraphicsFlickablePrivate::fixupX()
} else {
flicked = false;
}
+
+ vTime = timeline.time();
}
void QmlGraphicsFlickablePrivate::fixupY()
@@ -283,8 +285,6 @@ void QmlGraphicsFlickablePrivate::fixupY()
if (!q->yflick() || _moveY.timeLine())
return;
- vTime = timeline.time();
-
if (_moveY.value() > q->minYExtent() || (q->maxYExtent() > q->minYExtent())) {
timeline.reset(_moveY);
if (_moveY.value() != q->minYExtent())
@@ -297,6 +297,8 @@ void QmlGraphicsFlickablePrivate::fixupY()
} else {
flicked = false;
}
+
+ vTime = timeline.time();
}
void QmlGraphicsFlickablePrivate::updateBeginningEnd()
@@ -447,6 +449,7 @@ void QmlGraphicsFlickable::setViewportX(qreal pos)
Q_D(QmlGraphicsFlickable);
pos = qRound(pos);
d->timeline.reset(d->_moveX);
+ d->vTime = d->timeline.time();
if (-pos != d->_moveX.value()) {
d->_moveX.setValue(-pos);
viewportMoved();
@@ -464,6 +467,7 @@ void QmlGraphicsFlickable::setViewportY(qreal pos)
Q_D(QmlGraphicsFlickable);
pos = qRound(pos);
d->timeline.reset(d->_moveY);
+ d->vTime = d->timeline.time();
if (-pos != d->_moveY.value()) {
d->_moveY.setValue(-pos);
viewportMoved();
@@ -491,6 +495,7 @@ void QmlGraphicsFlickable::setInteractive(bool interactive)
d->interactive = interactive;
if (!interactive && d->flicked) {
d->timeline.clear();
+ d->vTime = d->timeline.time();
d->flicked = false;
emit flickingChanged();
emit flickEnded();
@@ -837,56 +842,57 @@ void QmlGraphicsFlickable::viewportMoved()
Q_D(QmlGraphicsFlickable);
int elapsed = QmlGraphicsItemPrivate::elapsed(d->velocityTime);
+ if (!elapsed)
+ return;
- if (elapsed) {
- qreal prevY = d->lastFlickablePosition.x();
- qreal prevX = d->lastFlickablePosition.y();
- d->velocityTimeline.clear();
- if (d->pressed) {
- qreal horizontalVelocity = (prevX - d->_moveX.value()) * 1000 / elapsed;
- qreal verticalVelocity = (prevY - d->_moveY.value()) * 1000 / elapsed;
- d->velocityTimeline.move(d->horizontalVelocity, horizontalVelocity, d->reportedVelocitySmoothing);
- d->velocityTimeline.move(d->horizontalVelocity, 0, d->reportedVelocitySmoothing);
- d->velocityTimeline.move(d->verticalVelocity, verticalVelocity, d->reportedVelocitySmoothing);
- d->velocityTimeline.move(d->verticalVelocity, 0, d->reportedVelocitySmoothing);
- } else {
- if (d->timeline.time() != d->vTime) {
- qreal horizontalVelocity = (prevX - d->_moveX.value()) * 1000 / (d->timeline.time() - d->vTime);
- qreal verticalVelocity = (prevY - d->_moveY.value()) * 1000 / (d->timeline.time() - d->vTime);
- d->horizontalVelocity.setValue(horizontalVelocity);
- d->verticalVelocity.setValue(verticalVelocity);
- }
- d->vTime = d->timeline.time();
+ qreal prevY = d->lastFlickablePosition.x();
+ qreal prevX = d->lastFlickablePosition.y();
+ d->velocityTimeline.clear();
+ if (d->pressed) {
+ qreal horizontalVelocity = (prevX - d->_moveX.value()) * 1000 / elapsed;
+ qreal verticalVelocity = (prevY - d->_moveY.value()) * 1000 / elapsed;
+ d->velocityTimeline.move(d->horizontalVelocity, horizontalVelocity, d->reportedVelocitySmoothing);
+ d->velocityTimeline.move(d->horizontalVelocity, 0, d->reportedVelocitySmoothing);
+ d->velocityTimeline.move(d->verticalVelocity, verticalVelocity, d->reportedVelocitySmoothing);
+ d->velocityTimeline.move(d->verticalVelocity, 0, d->reportedVelocitySmoothing);
+ } else {
+ if (d->timeline.time() > d->vTime) {
+ qreal horizontalVelocity = (prevX - d->_moveX.value()) * 1000 / (d->timeline.time() - d->vTime);
+ qreal verticalVelocity = (prevY - d->_moveY.value()) * 1000 / (d->timeline.time() - d->vTime);
+ d->horizontalVelocity.setValue(horizontalVelocity);
+ d->verticalVelocity.setValue(verticalVelocity);
}
}
- d->lastFlickablePosition = QPointF(d->_moveY.value(), d->_moveX.value());
QmlGraphicsItemPrivate::restart(d->velocityTime);
- d->updateBeginningEnd();
+ d->lastFlickablePosition = QPointF(d->_moveY.value(), d->_moveX.value());
- if (d->flicked) {
+ if (d->flicked && d->timeline.time() > d->vTime) {
// Near an end and it seems that the extent has changed?
// Recalculate the flick so that we don't end up in an odd position.
if (d->velocityY > 0) {
const qreal minY = minYExtent();
- if (minY - d->_moveY.value() < height()/3 && minY != d->flickTargetY)
+ if (minY - d->_moveY.value() < height()/2 && minY != d->flickTargetY)
d->flickY(-d->verticalVelocity.value());
- } else {
+ } else if (d->velocityY < 0) {
const qreal maxY = maxYExtent();
- if (d->_moveY.value() - maxY < height()/3 && maxY != d->flickTargetY)
+ if (d->_moveY.value() - maxY < height()/2 && maxY != d->flickTargetY)
d->flickY(-d->verticalVelocity.value());
}
if (d->velocityX > 0) {
const qreal minX = minXExtent();
- if (minX - d->_moveX.value() < height()/3 && minX != d->flickTargetX)
+ if (minX - d->_moveX.value() < height()/2 && minX != d->flickTargetX)
d->flickX(-d->horizontalVelocity.value());
- } else {
+ } else if (d->velocityX < 0) {
const qreal maxX = maxXExtent();
- if (d->_moveX.value() - maxX < height()/3 && maxX != d->flickTargetX)
+ if (d->_moveX.value() - maxX < height()/2 && maxX != d->flickTargetX)
d->flickX(-d->horizontalVelocity.value());
}
}
+
+ d->vTime = d->timeline.time();
+ d->updateBeginningEnd();
}
void QmlGraphicsFlickable::cancelFlick()
diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
index fd8b8b0..fc1ec4a 100644
--- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
@@ -815,8 +815,9 @@ void QmlGraphicsListViewPrivate::fixupY()
if (haveHighlightRange && highlightRange == QmlGraphicsListView::StrictlyEnforceRange) {
if (currentItem && highlight && currentItem->position() != highlight->position()) {
moveReason = Mouse;
- timeline.clear();
+ timeline.reset(_moveY);
timeline.move(_moveY, -(currentItem->position() - highlightRangeStart), QEasingCurve(QEasingCurve::InOutQuad), 200);
+ vTime = timeline.time();
}
}
}
@@ -830,8 +831,9 @@ void QmlGraphicsListViewPrivate::fixupX()
if (haveHighlightRange && highlightRange == QmlGraphicsListView::StrictlyEnforceRange) {
if (currentItem && highlight && currentItem->position() != highlight->position()) {
moveReason = Mouse;
- timeline.clear();
+ timeline.reset(_moveX);
timeline.move(_moveX, -(currentItem->position() - highlightRangeStart), QEasingCurve(QEasingCurve::InOutQuad), 200);
+ vTime = timeline.time();
}
}
}
diff --git a/src/declarative/graphicsitems/qmlgraphicsloader.cpp b/src/declarative/graphicsitems/qmlgraphicsloader.cpp
index 3b10908..c466c44 100644
--- a/src/declarative/graphicsitems/qmlgraphicsloader.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsloader.cpp
@@ -45,7 +45,8 @@
QT_BEGIN_NAMESPACE
QmlGraphicsLoaderPrivate::QmlGraphicsLoaderPrivate()
-: item(0), component(0), ownComponent(false), resizeMode(QmlGraphicsLoader::SizeLoaderToItem)
+ : item(0), component(0), ownComponent(false)
+ , resizeMode(QmlGraphicsLoader::SizeLoaderToItem)
{
}
@@ -53,6 +54,36 @@ QmlGraphicsLoaderPrivate::~QmlGraphicsLoaderPrivate()
{
}
+void QmlGraphicsLoaderPrivate::clear()
+{
+ if (ownComponent) {
+ delete component;
+ component = 0;
+ ownComponent = false;
+ }
+ source = QUrl();
+
+ delete item;
+ item = 0;
+}
+
+void QmlGraphicsLoaderPrivate::initResize()
+{
+ Q_Q(QmlGraphicsLoader);
+
+ QmlGraphicsItem *resizeItem = 0;
+ if (resizeMode == QmlGraphicsLoader::SizeLoaderToItem)
+ resizeItem = item;
+ else if (resizeMode == QmlGraphicsLoader::SizeItemToLoader)
+ resizeItem = q;
+ if (resizeItem) {
+ QObject::connect(resizeItem, SIGNAL(widthChanged()), q, SLOT(_q_updateSize()));
+ QObject::connect(resizeItem, SIGNAL(heightChanged()), q, SLOT(_q_updateSize()));
+ }
+ _q_updateSize();
+}
+
+
QML_DEFINE_TYPE(Qt,4,6,Loader,QmlGraphicsLoader)
/*!
@@ -74,6 +105,17 @@ QML_DEFINE_TYPE(Qt,4,6,Loader,QmlGraphicsLoader)
MouseRegion { anchors.fill: parent; onClicked: pageLoader.source = "Page1.qml" }
}
\endcode
+
+ If the Loader source is changed, any previous items instantiated
+ will be destroyed. Setting \c source to an empty string
+ will destroy the currently instantiated items, freeing resources
+ and leaving the Loader empty. For example:
+
+ \code
+ pageLoader.source = ""
+ \endcode
+
+ unloads "Page1.qml" and frees resources consumed by it.
*/
/*!
@@ -102,7 +144,7 @@ QmlGraphicsLoader::~QmlGraphicsLoader()
This property holds the URL of the QML component to
instantiate.
- \sa status, progress
+ \sa sourceComponent, status, progress
*/
QUrl QmlGraphicsLoader::source() const
{
@@ -116,12 +158,7 @@ void QmlGraphicsLoader::setSource(const QUrl &url)
if (d->source == url)
return;
- if (d->ownComponent) {
- delete d->component;
- d->component = 0;
- }
- delete d->item;
- d->item = 0;
+ d->clear();
d->source = url;
if (d->source.isEmpty()) {
@@ -164,7 +201,7 @@ void QmlGraphicsLoader::setSource(const QUrl &url)
}
\endqml
- \sa source
+ \sa source, progress
*/
QmlComponent *QmlGraphicsLoader::sourceComponent() const
@@ -179,13 +216,7 @@ void QmlGraphicsLoader::setSourceComponent(QmlComponent *comp)
if (comp == d->component)
return;
- d->source = QUrl();
- if (d->ownComponent) {
- delete d->component;
- d->component = 0;
- }
- delete d->item;
- d->item = 0;
+ d->clear();
d->component = comp;
d->ownComponent = false;
@@ -233,16 +264,7 @@ void QmlGraphicsLoaderPrivate::_q_sourceLoaded()
if (item) {
item->setParentItem(q);
// item->setFocus(true);
- QmlGraphicsItem *resizeItem = 0;
- if (resizeMode == QmlGraphicsLoader::SizeLoaderToItem)
- resizeItem = item;
- else if (resizeMode == QmlGraphicsLoader::SizeItemToLoader)
- resizeItem = q;
- if (resizeItem) {
- QObject::connect(resizeItem, SIGNAL(widthChanged()), q, SLOT(_q_updateSize()));
- QObject::connect(resizeItem, SIGNAL(heightChanged()), q, SLOT(_q_updateSize()));
- }
- _q_updateSize();
+ initResize();
}
} else {
delete obj;
@@ -340,20 +362,7 @@ void QmlGraphicsLoader::setResizeMode(ResizeMode mode)
}
d->resizeMode = mode;
-
- if (d->item) {
- QmlGraphicsItem *resizeItem = 0;
- if (d->resizeMode == SizeLoaderToItem)
- resizeItem = d->item;
- else if (d->resizeMode == SizeItemToLoader)
- resizeItem = this;
- if (resizeItem) {
- connect(resizeItem, SIGNAL(widthChanged()), this, SLOT(_q_updateSize()));
- connect(resizeItem, SIGNAL(heightChanged()), this, SLOT(_q_updateSize()));
- }
-
- d->_q_updateSize();
- }
+ d->initResize();
}
void QmlGraphicsLoaderPrivate::_q_updateSize()
diff --git a/src/declarative/graphicsitems/qmlgraphicsloader_p.h b/src/declarative/graphicsitems/qmlgraphicsloader_p.h
index 8cd1819..ad516b4 100644
--- a/src/declarative/graphicsitems/qmlgraphicsloader_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsloader_p.h
@@ -63,7 +63,6 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsLoader : public QmlGraphicsItem
Q_PROPERTY(QmlGraphicsItem *item READ item NOTIFY itemChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
- //### sourceItem
public:
QmlGraphicsLoader(QmlGraphicsItem *parent=0);
diff --git a/src/declarative/graphicsitems/qmlgraphicsloader_p_p.h b/src/declarative/graphicsitems/qmlgraphicsloader_p_p.h
index 23fedb7..cd7316d 100644
--- a/src/declarative/graphicsitems/qmlgraphicsloader_p_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsloader_p_p.h
@@ -67,10 +67,13 @@ public:
QmlGraphicsLoaderPrivate();
~QmlGraphicsLoaderPrivate();
+ void clear();
+ void initResize();
+
QUrl source;
QmlGraphicsItem *item;
QmlComponent *component;
- bool ownComponent;
+ bool ownComponent : 1;
QmlGraphicsLoader::ResizeMode resizeMode;
void _q_sourceLoaded();
diff --git a/tests/auto/declarative/listview/data/listview-sections.qml b/tests/auto/declarative/listview/data/listview-sections.qml
new file mode 100644
index 0000000..56700be
--- /dev/null
+++ b/tests/auto/declarative/listview/data/listview-sections.qml
@@ -0,0 +1,59 @@
+import Qt 4.6
+
+Rectangle {
+ width: 240
+ height: 320
+ color: "#ffffff"
+ resources: [
+ Component {
+ id: myDelegate
+ Item {
+ id: wrapper
+ objectName: "wrapper"
+ height: ListView.prevSection != ListView.section ? 40 : 20;
+ width: 240
+ Rectangle {
+ y: wrapper.ListView.prevSection != wrapper.ListView.section ? 20 : 0
+ height: 20
+ width: parent.width
+ color: wrapper.ListView.isCurrentItem ? "lightsteelblue" : "white"
+ Text {
+ text: index
+ }
+ Text {
+ x: 30
+ id: textName
+ objectName: "textName"
+ text: name
+ }
+ Text {
+ x: 120
+ id: textNumber
+ objectName: "textNumber"
+ text: number
+ }
+ Text {
+ x: 200
+ text: wrapper.y
+ }
+ }
+ Rectangle {
+ color: "#99bb99"
+ height: wrapper.ListView.prevSection != wrapper.ListView.section ? 20 : 0
+ width: parent.width
+ visible: wrapper.ListView.prevSection != wrapper.ListView.section ? true : false
+ Text { text: wrapper.ListView.section }
+ }
+ }
+ }
+ ]
+ ListView {
+ id: list
+ objectName: "list"
+ width: 240
+ height: 320
+ model: testModel
+ delegate: myDelegate
+ sectionExpression: "Math.floor(index/5)"
+ }
+}
diff --git a/tests/auto/declarative/listview/tst_listview.cpp b/tests/auto/declarative/listview/tst_listview.cpp
index 6bf1080..b8f87b7 100644
--- a/tests/auto/declarative/listview/tst_listview.cpp
+++ b/tests/auto/declarative/listview/tst_listview.cpp
@@ -70,6 +70,8 @@ private slots:
void qAbstractItemModel_moved();
void enforceRange();
+ void spacing();
+ void sections();
private:
template <class T> void items();
@@ -264,6 +266,13 @@ void tst_QmlGraphicsListView::items()
listview->decrementCurrentIndex();
QCOMPARE(listview->currentIndex(), 0);
+ // set an empty model and confirm that items are destroyed
+ T model2;
+ ctxt->setContextProperty("testModel", &model2);
+
+ int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
+ QVERIFY(itemCount == 0);
+
delete canvas;
}
@@ -632,6 +641,91 @@ void tst_QmlGraphicsListView::enforceRange()
delete canvas;
}
+void tst_QmlGraphicsListView::spacing()
+{
+ QmlView *canvas = createView(SRCDIR "/data/listview.qml");
+
+ TestModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->execute();
+ qApp->processEvents();
+
+ QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "list");
+ QVERIFY(listview != 0);
+
+ QmlGraphicsItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->y() == i*20);
+ }
+
+ listview->setSpacing(10);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->y() == i*30);
+ }
+
+ listview->setSpacing(0);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->y() == i*20);
+ }
+
+ delete canvas;
+}
+
+void tst_QmlGraphicsListView::sections()
+{
+ QmlView *canvas = createView(SRCDIR "/data/listview-sections.qml");
+
+ TestModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->execute();
+ qApp->processEvents();
+
+ QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "list");
+ QVERIFY(listview != 0);
+
+ QmlGraphicsItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
+ QVERIFY(item);
+ QCOMPARE(item->y(), qreal(i*20 + ((i+4)/5) * 20));
+ }
+
+ delete canvas;
+}
+
void tst_QmlGraphicsListView::qListModelInterface_items()
{
items<TestModel>();
diff --git a/tests/auto/declarative/qfxloader/tst_qfxloader.cpp b/tests/auto/declarative/qfxloader/tst_qfxloader.cpp
index 9a8f8f1..9a3da90 100644
--- a/tests/auto/declarative/qfxloader/tst_qfxloader.cpp
+++ b/tests/auto/declarative/qfxloader/tst_qfxloader.cpp
@@ -110,14 +110,21 @@ void tst_qfxloader::component()
void tst_qfxloader::clear()
{
- QmlComponent component(&engine, QByteArray("import Qt 4.6\nLoader { source: \"Rect120x60.qml\" }"), QUrl("file://" SRCDIR "/"));
+ QmlComponent component(&engine, QByteArray(
+ "import Qt 4.6\n"
+ " Loader { id: loader\n"
+ " source: 'Rect120x60.qml'\n"
+ " Timer { interval: 200; running: true; onTriggered: loader.source = '' }\n"
+ " }")
+ , QUrl("file://" SRCDIR "/"));
QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
QVERIFY(loader != 0);
QVERIFY(loader->item());
QCOMPARE(loader->progress(), 1.0);
QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
- loader->setSource(QUrl(""));
+ QTest::qWait(500);
+
QVERIFY(loader->item() == 0);
QCOMPARE(loader->progress(), 0.0);
QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0);
@@ -136,7 +143,7 @@ void tst_qfxloader::urlToComponent()
"}" )
, QUrl("file://" SRCDIR "/"));
QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QTest::qWait(1000);
+ QTest::qWait(500);
QVERIFY(loader != 0);
QVERIFY(loader->item());
QCOMPARE(loader->progress(), 1.0);