diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2023-05-10 13:17:50 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-05-12 15:06:42 +0200 |
commit | c8cba48b92575d0e7ffcdc910b38e02d232f6c21 (patch) | |
tree | 0cd3ccf97102ad09b77a1479d3247d957a4eecc2 /tests/auto/qml/qqmlcomponent | |
parent | d88b52b541a0482b69639dbea8976287db9ca52b (diff) |
QQmlComponent: Remove pending QProperty bindings in old createObject()
When calling the QQmlV4Function overload of createObject() we end up in
a different code path. The problem is the same, though.
Amends commit ef6e9f6b75848dfdacdd98cf9e7530f651b3dfca.
Pick-to: 6.5
Task-number: QTBUG-99363
Change-Id: I6341243b75d9db1e0fcb80d8d73dab6932d85fd2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlcomponent')
-rw-r--r-- | tests/auto/qml/qqmlcomponent/data/removeBinding.qml | 11 | ||||
-rw-r--r-- | tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp | 12 |
2 files changed, 22 insertions, 1 deletions
diff --git a/tests/auto/qml/qqmlcomponent/data/removeBinding.qml b/tests/auto/qml/qqmlcomponent/data/removeBinding.qml index 08126a1db2..091f6991be 100644 --- a/tests/auto/qml/qqmlcomponent/data/removeBinding.qml +++ b/tests/auto/qml/qqmlcomponent/data/removeBinding.qml @@ -18,4 +18,15 @@ QtObject { const item = customItem.createObject(root, properties) return item.objectName; } + + property string result2: { + const properties = { + "objectName": "43", + } + + // add some junk argument to trigger the QQmlV4Function overload + const item = customItem.createObject(root, properties, 13) + + return item.objectName; + } } diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp index d6a14cd3ef..8e46b38b5a 100644 --- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp +++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -1450,11 +1450,21 @@ void tst_qqmlcomponent::loadFromQrc() void tst_qqmlcomponent::removeBinding() { QQmlEngine e; - QQmlComponent c(&e, testFileUrl("removeBinding.qml")); + const QUrl url = testFileUrl("removeBinding.qml"); + QQmlComponent c(&e, url); QVERIFY2(c.isReady(), qPrintable(c.errorString())); + + QTest::ignoreMessage( + QtWarningMsg, + qPrintable(url.toString() + QStringLiteral(":7:27: QML Component: Unsuitable arguments " + "passed to createObject(). The first argument " + "should be a QObject* or null, and the second " + "argument should be a JavaScript object or a " + "QVariantMap"))); QScopedPointer<QObject> o(c.create()); QVERIFY(!o.isNull()); QCOMPARE(o->property("result"), QStringLiteral("42")); + QCOMPARE(o->property("result2"), QStringLiteral("43")); } void tst_qqmlcomponent::complexObjectArgument() |