diff options
author | Joona Petrell <joona.t.petrell@nokia.com> | 2010-09-21 06:25:48 (GMT) |
---|---|---|
committer | Joona Petrell <joona.t.petrell@nokia.com> | 2010-09-21 07:09:12 (GMT) |
commit | 46e49547f8e4614cd504b0af0d52d4e2768b57c3 (patch) | |
tree | 6b03de15d71e0539edd4f9ff3314a0292298dab4 /tests/auto/declarative/qdeclarativelistmodel | |
parent | bf37d0708afbf4df8eb4ffcba60538a53083edaa (diff) | |
download | Qt-46e49547f8e4614cd504b0af0d52d4e2768b57c3.zip Qt-46e49547f8e4614cd504b0af0d52d4e2768b57c3.tar.gz Qt-46e49547f8e4614cd504b0af0d52d4e2768b57c3.tar.bz2 |
Fix a crash in QDeclarativeVisualDataModel
Task-number: QTBUG-13754
Reviewed-by: Martin Jones
Diffstat (limited to 'tests/auto/declarative/qdeclarativelistmodel')
-rw-r--r-- | tests/auto/declarative/qdeclarativelistmodel/data/multipleroles.qml | 25 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp | 16 |
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/multipleroles.qml b/tests/auto/declarative/qdeclarativelistmodel/data/multipleroles.qml new file mode 100644 index 0000000..b8f2f32 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelistmodel/data/multipleroles.qml @@ -0,0 +1,25 @@ +import Qt 4.7 +ListView { + width: 100 + height: 250 + delegate: Rectangle { + width: 100 + height: 50 + color: black ? "black": "white" + } + model: ListModel { + objectName: "listModel" + ListElement { + black: false + rounded: false + } + ListElement { + black: true + rounded: false + } + ListElement { + black: true + rounded: false + } + } +}
\ No newline at end of file diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index f456778..31cb545 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -98,6 +98,7 @@ private slots: void get_worker_data(); void get_nested(); void get_nested_data(); + void crash_model_with_multiple_roles(); }; int tst_qdeclarativelistmodel::roleFromName(const QDeclarativeListModel *model, const QString &roleName) { @@ -886,6 +887,21 @@ void tst_qdeclarativelistmodel::get_nested_data() get_data(); } +//QTBUG-13754 +void tst_qdeclarativelistmodel::crash_model_with_multiple_roles() +{ + QDeclarativeEngine eng; + QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/multipleroles.qml")); + QObject *rootItem = component.create(); + QVERIFY(component.errorString().isEmpty()); + QVERIFY(rootItem != 0); + QDeclarativeListModel *model = rootItem->findChild<QDeclarativeListModel*>("listModel"); + QVERIFY(model != 0); + + // used to cause a crash in QDeclarativeVisualDataModel + model->setProperty(0, "black", true); +} + QTEST_MAIN(tst_qdeclarativelistmodel) #include "tst_qdeclarativelistmodel.moc" |