aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2024-08-09 15:40:24 +0200
committerUlf Hermann <ulf.hermann@qt.io>2024-08-12 16:19:40 +0200
commit9f554ef8cf19e9c30c1ba9d37d9579239a5aab87 (patch)
tree869fd695f26bc9c64e493d68ee8583f7836f2a04 /tests/auto/qml/qmlcppcodegen
parent7c404391c3971a7d20a6a64f25a7c89d65fab9db (diff)
QmlCompiler: Do not choose unstorable stored types
In order to pass the argument to a value type ctor we need to store it in something we can rely on. Amends commmit dd731b880b4bfbe7bad7b0b4d1ac3b72503c0071 Change-Id: I5d1ef6b4611aad9b595235f4f874ef4a063f04c6 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen')
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/multipleCtors.qml5
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/withlength.h9
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp1
3 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/multipleCtors.qml b/tests/auto/qml/qmlcppcodegen/data/multipleCtors.qml
index 61dfdb7ca5..fcce6aa74a 100644
--- a/tests/auto/qml/qmlcppcodegen/data/multipleCtors.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/multipleCtors.qml
@@ -6,8 +6,13 @@ import QtQml
QtObject {
property rect r: Qt.rect(1, 2, 3, 4)
property point p: Qt.point(5, 6);
+ property ObjectType o: ObjectType {
+ id: oo
+ property int makeItASeparateType: 1
+ }
property withLength wr: r
property withLength wp: p
property withLength wi: 17
+ property withLength wo: oo
}
diff --git a/tests/auto/qml/qmlcppcodegen/data/withlength.h b/tests/auto/qml/qmlcppcodegen/data/withlength.h
index 26c6307f2b..ed7abe85dd 100644
--- a/tests/auto/qml/qmlcppcodegen/data/withlength.h
+++ b/tests/auto/qml/qmlcppcodegen/data/withlength.h
@@ -9,6 +9,14 @@
#include <QtCore/qrect.h>
#include <QtQml/qqml.h>
+class ObjectType : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+public:
+ ObjectType(QObject *parent = nullptr) : QObject(parent) {}
+};
+
struct ValueTypeWithLength
{
Q_GADGET
@@ -23,6 +31,7 @@ public:
Q_INVOKABLE ValueTypeWithLength(QPointF point) : m_length(point.manhattanLength()) {}
Q_INVOKABLE ValueTypeWithLength(QRectF rect) : m_length(rect.width()) {}
Q_INVOKABLE QString toString() const { return QStringLiteral("no"); }
+ Q_INVOKABLE ValueTypeWithLength(ObjectType *) : m_length(-4) {}
int length() const { return m_length; }
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index c456376cfe..888bb098e5 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -3504,6 +3504,7 @@ void tst_QmlCppCodegen::multipleCtors()
QCOMPARE(o->property("wr").value<ValueTypeWithLength>().length(), 3);
QCOMPARE(o->property("wp").value<ValueTypeWithLength>().length(), 11);
QCOMPARE(o->property("wi").value<ValueTypeWithLength>().length(), 17);
+ QCOMPARE(o->property("wo").value<ValueTypeWithLength>().length(), -4);
}
void tst_QmlCppCodegen::namespaceWithEnum()