From 3359cfcae098401b4d18e5ca4f4f09763c9cea1c Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 6 May 2022 09:57:07 +0200 Subject: Generalize role selection mechanism from QQuickComboBox We can have QQmlDelegateModel pick specific roles from model items. That can easily be done for variant maps, variant hashes, objects and gadgets. We would like to do it for anything that has a QMetaAssociation, but as we cannot get to the original type at that place, it's currently not possible. The special case about variant maps with exactly one item in variant lists is clearly insane and therefore not included in the generalization. This requires some cleanup in the QQmlGadgetPointerWrapper. Passing the wrapper itself to QMetaProperty::read() has always been a rather obscure way of reading from the gadget. Fixes: QTBUG-102983 Change-Id: I84ecef980783e7137aa4d77070ddce47b6ead260 Reviewed-by: Fabian Kosmale (cherry picked from commit d0c7c7234cb7629fbe7a04944cb5191414cc72b9) --- tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp index 402a68afae..5d426cff4f 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -1943,8 +1943,8 @@ void tst_qqmlproperty::variantMapHandling() void tst_qqmlproperty::crashOnValueProperty() { - QQmlEngine *engine = new QQmlEngine; - QQmlComponent component(engine); + QScopedPointer engine(new QQmlEngine); + QQmlComponent component(engine.data()); component.setData("import Test 1.0\nPropertyObject { wrectProperty.x: 10 }", QUrl()); QScopedPointer object(component.create()); @@ -1957,8 +1957,7 @@ void tst_qqmlproperty::crashOnValueProperty() QCOMPARE(p.read(), QVariant(10)); //don't crash once the engine is deleted - delete engine; - engine = nullptr; + engine.reset(); QCOMPARE(p.propertyTypeName(), "int"); QCOMPARE(p.read(), QVariant(10)); -- cgit v1.2.3