aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTasuku Suzuki <stasuku@gmail.com>2013-01-17 18:46:45 +0900
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-18 18:19:16 +0100
commit9e604dcd07d5b943520ab2a3d472bd23fdd577ec (patch)
treec627d6ff4f9b8ade492772f98ba4c0beacf6848a
parent0d17d4a19c07e475920dcb0d0c57a8717ba98844 (diff)
Fix crash in PathView
Change-Id: I259e7af1755ff9615782bbce03fc41ea1957cab3 Task-number: QTBUG-29176 Reviewed-by: Alan Alpert <aalpert@rim.com>
-rw-r--r--src/quick/items/qquickpathview.cpp10
-rw-r--r--tests/auto/quick/qquickpathview/data/emptypath.qml6
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp14
3 files changed, 27 insertions, 3 deletions
diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp
index a58ed599be..a7be50bc11 100644
--- a/src/quick/items/qquickpathview.cpp
+++ b/src/quick/items/qquickpathview.cpp
@@ -193,7 +193,7 @@ void QQuickPathView::initItem(int index, QQuickItem *item)
if (att) {
att->m_view = this;
qreal percent = d->positionOfIndex(index);
- if (percent < 1.0) {
+ if (percent < 1.0 && d->path) {
foreach (const QString &attr, d->path->attributes())
att->setValue(attr.toUtf8(), d->path->attributeAt(attr, percent));
item->setZ(d->requestedZ);
@@ -227,8 +227,10 @@ QQmlOpenMetaObjectType *QQuickPathViewPrivate::attachedType()
if (!attType) {
// pre-create one metatype to share with all attached objects
attType = new QQmlOpenMetaObjectType(&QQuickPathViewAttached::staticMetaObject, qmlEngine(q));
- foreach (const QString &attr, path->attributes())
- attType->createProperty(attr.toUtf8());
+ if (path) {
+ foreach (const QString &attr, path->attributes())
+ attType->createProperty(attr.toUtf8());
+ }
}
return attType;
@@ -423,6 +425,8 @@ void QQuickPathView::pathUpdated()
void QQuickPathViewPrivate::updateItem(QQuickItem *item, qreal percent)
{
+ if (!path)
+ return;
if (QQuickPathViewAttached *att = attached(item)) {
if (qFuzzyCompare(att->m_percent, percent))
return;
diff --git a/tests/auto/quick/qquickpathview/data/emptypath.qml b/tests/auto/quick/qquickpathview/data/emptypath.qml
new file mode 100644
index 0000000000..d68cf4491b
--- /dev/null
+++ b/tests/auto/quick/qquickpathview/data/emptypath.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.0
+
+PathView {
+ model: 1
+ delegate: Item {}
+}
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
index a7e0f2feb4..8821203902 100644
--- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -118,6 +118,7 @@ private slots:
void pathUpdateOnStartChanged();
void package();
void emptyModel();
+ void emptyPath();
void closed();
void pathUpdate();
void visualDataModel();
@@ -1373,6 +1374,19 @@ void tst_QQuickPathView::emptyModel()
delete window;
}
+void tst_QQuickPathView::emptyPath()
+{
+ QQuickView *window = createView();
+
+ window->setSource(testFileUrl("emptypath.qml"));
+ qApp->processEvents();
+
+ QQuickPathView *pathview = qobject_cast<QQuickPathView*>(window->rootObject());
+ QVERIFY(pathview != 0);
+
+ delete window;
+}
+
void tst_QQuickPathView::closed()
{
QQmlEngine engine;