aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
diff options
context:
space:
mode:
authorTarja Sundqvist <tarja.sundqvist@qt.io>2025-12-15 16:14:22 +0200
committerTarja Sundqvist <tarja.sundqvist@qt.io>2025-12-15 16:14:22 +0200
commitb58ec3b086518da5aa573f99426235854c23e35f (patch)
tree861a9935d8f1cdba2fdca546836a351736dbddbf /tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
parent4826f86e274f1b29bd769e6790824f9e62a40f62 (diff)
parent22032227d16c39211e2ebceef97d21f4d89c7c87 (diff)
Merge tag 'v6.5.8-lts-lgpl' into 6.56.5
Qt 6.5.8-lts-lgpl release
Diffstat (limited to 'tests/auto/qml/qqmlengine/tst_qqmlengine.cpp')
-rw-r--r--tests/auto/qml/qqmlengine/tst_qqmlengine.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
index b82a1f4174..bf68de0d2f 100644
--- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
+++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
@@ -79,6 +79,7 @@ private slots:
void lockedRootObject();
void crossReferencingSingletonsDeletion();
void bindingInstallUseAfterFree();
+ void attachedObjectOfUnregistered();
public slots:
QObject *createAQObjectForOwnershipTest ()
@@ -1708,6 +1709,42 @@ void tst_qqmlengine::bindingInstallUseAfterFree()
QVERIFY(o);
}
+class UnregisteredAttached : public QObject
+{
+ Q_OBJECT
+public:
+ UnregisteredAttached(QObject *parent = nullptr) : QObject(parent) {}
+};
+
+class Unregistered : public QObject
+{
+ Q_OBJECT
+ QML_ATTACHED(UnregisteredAttached)
+public:
+ static UnregisteredAttached *qmlAttachedProperties(QObject *obj)
+ {
+ return new UnregisteredAttached(obj);
+ }
+};
+
+void tst_qqmlengine::attachedObjectOfUnregistered()
+{
+ QObject o;
+
+ QObject *a = qmlAttachedPropertiesObject<Unregistered>(&o);
+ QVERIFY(a);
+ QVERIFY(qobject_cast<UnregisteredAttached *>(a));
+
+ QObject *b = qmlAttachedPropertiesObject<Unregistered>(&o);
+ QCOMPARE(a, b);
+
+ QObject o2;
+ QObject *c = qmlAttachedPropertiesObject<Unregistered>(&o2);
+ QVERIFY(c);
+ QVERIFY(qobject_cast<UnregisteredAttached *>(c));
+ QVERIFY(c != a);
+}
+
QTEST_MAIN(tst_qqmlengine)
#include "tst_qqmlengine.moc"