diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-09-15 10:12:21 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-10-01 14:04:02 +0200 |
commit | de28bc00f514c3ee8d8fd3166973c063766e77fd (patch) | |
tree | dd7e8741f1bdb2c6dc51595dde5844e2d81e9d6b /tests/auto/qml/bindingdependencyapi | |
parent | 61128f2578954c576d00c20ce74eafe2eb0ccd77 (diff) |
QQmlBinding::dependencies: Handle QProperty
The method did not consider QProperty properties, as those do not show
up via the active guards mechanism.
At some point, we probably also want to introduce
QQmlAnyBinding::dependencies, as there are now bindings which do not
derive from QQmlBinding.
Pick-to: 6.2
Change-Id: Ib4b227a440e9494c09d92028f9eaa5ad1e87342f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Diffstat (limited to 'tests/auto/qml/bindingdependencyapi')
-rw-r--r-- | tests/auto/qml/bindingdependencyapi/tst_bindingdependencyapi.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/qml/bindingdependencyapi/tst_bindingdependencyapi.cpp b/tests/auto/qml/bindingdependencyapi/tst_bindingdependencyapi.cpp index dfb595ffb0..81162c2c8a 100644 --- a/tests/auto/qml/bindingdependencyapi/tst_bindingdependencyapi.cpp +++ b/tests/auto/qml/bindingdependencyapi/tst_bindingdependencyapi.cpp @@ -48,6 +48,7 @@ private slots: void testConditionalDependencies_data(); void testConditionalDependencies(); void testBindingLoop(); + void testQproperty(); private: bool findProperties(const QVector<QQmlProperty> &properties, QObject *obj, const QString &propertyName, const QVariant &value); @@ -354,6 +355,36 @@ void tst_bindingdependencyapi::testBindingLoop() delete rect; } +void tst_bindingdependencyapi::testQproperty() +{ + QQmlEngine engine; + QQmlComponent c(&engine); + c.setData(QByteArray("import QtQuick 2.0\n" + "Item {\n" + "id: root\n" + "Text {\n" + "id: label\n" + "text: root.x\n" + "}\n" + "}"), QUrl()); + QScopedPointer<QObject> root(c.create()); + QVERIFY(!root.isNull()); + QObject *text = root->findChildren<QQuickText *>().front(); + QVERIFY(text); + auto data = QQmlData::get(text); + QVERIFY(data); + auto b = data->bindings; + QVERIFY(b); + auto binding = dynamic_cast<QQmlBinding*>(b); + QVERIFY(binding); + auto dependencies = binding->dependencies(); + QCOMPARE(dependencies.size(), 1); + auto dependency = dependencies.front(); + QVERIFY(dependency.isValid()); + QCOMPARE(quintptr(dependency.object()), quintptr(root.get())); + QCOMPARE(dependency.property().name(), "x"); +} + QTEST_MAIN(tst_bindingdependencyapi) #include "tst_bindingdependencyapi.moc" |