diff options
Diffstat (limited to 'tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp')
-rw-r--r-- | tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp index a9b6ec03a4..7f94180274 100644 --- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp +++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp @@ -136,6 +136,7 @@ private slots: void destroyObject(); void emptyStringNotUndefined(); void listElementWithTemplateString(); + void destroyComponentObject(); }; bool tst_qqmllistmodel::compareVariantList(const QVariantList &testList, QVariant object) @@ -1856,6 +1857,31 @@ void tst_qqmllistmodel::listElementWithTemplateString() QVERIFY(!root.isNull()); } +//QTBUG-95895 +void tst_qqmllistmodel::destroyComponentObject() +{ + QQmlEngine eng; + QQmlComponent component(&eng, testFileUrl("destroyObject.qml")); + QVERIFY(!component.isError()); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); + QQmlListModel *list = qvariant_cast<QQmlListModel *>(obj->property("projects")); + QVERIFY(list != nullptr); + QCOMPARE(list->count(), 1); + QPointer<QObject> created(qvariant_cast<QObject *>(obj->property("object"))); + QVERIFY(!created.isNull()); + QCOMPARE(list->get(0).property("obj").toQObject(), created.data()); + QVariant retVal; + QMetaObject::invokeMethod(obj.data(), + "destroy", + Qt::DirectConnection, + Q_RETURN_ARG(QVariant, retVal)); + QVERIFY(retVal.toBool()); + QTRY_VERIFY(created.isNull()); + QTRY_VERIFY(list->get(0).property("obj").isUndefined()); + QCOMPARE(list->count(), 1); +} + QTEST_MAIN(tst_qqmllistmodel) #include "tst_qqmllistmodel.moc" |