diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-06-10 11:23:20 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-06-10 20:40:56 +0000 |
commit | 2b8b69edc13d8abf49b68509b7a379f7ca1b7cb2 (patch) | |
tree | c83885c4784203febc173426feafdeee2cc1a94b /src | |
parent | 538c36af0a175451ea5a4f6f3d05ac68a7fc09a3 (diff) |
qmltyperegistrar: Parse value type lists
We need to generate isList properties for those, so that qmlcachegen and
qmllint can handle them.
Fixes: QTBUG-104129
Change-Id: I7e632279a605694c2fd5f583c8a6dcf9968eb634
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
(cherry picked from commit 8e69558f2f7d44f83779f7e1f60f811dfab0c275)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/qmltyperegistrar/qmltypescreator.cpp | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/qmltyperegistrar/qmltypescreator.cpp b/src/qmltyperegistrar/qmltypescreator.cpp index d2a4ad9fd8..836eb0c10b 100644 --- a/src/qmltyperegistrar/qmltypescreator.cpp +++ b/src/qmltyperegistrar/qmltypescreator.cpp @@ -182,17 +182,30 @@ void QmlTypesCreator::writeType(const QJsonObject &property, const QString &key) } else if (type == QLatin1String("quint64")) { type = QLatin1String("qulonglong"); } else { + auto handleList = [&](QLatin1String list) { + if (!type.startsWith(list) || !type.endsWith(QLatin1Char('>'))) + return false; - const QLatin1String listProperty("QQmlListProperty<"); - if (type.startsWith(listProperty)) { - isList = true; - const int listPropertySize = listProperty.size(); - type = type.mid(listPropertySize, type.size() - listPropertySize - 1); - } + const int listSize = list.size(); + const QString elementType = type.mid(listSize, type.size() - listSize - 1).trimmed(); + + // QQmlListProperty internally constructs the pointer. Passing an explicit '*' will + // produce double pointers. QList is only for value types. We can't handle QLists + // of pointers (unless specially registered, but then they're not isList). + if (elementType.endsWith(QLatin1Char('*'))) + return false; - if (type.endsWith(QLatin1Char('*'))) { - isPointer = true; - type = type.left(type.size() - 1); + isList = true; + type = elementType; + return true; + }; + + if (!handleList(QLatin1String("QQmlListProperty<")) + && !handleList(QLatin1String("QList<"))) { + if (type.endsWith(QLatin1Char('*'))) { + isPointer = true; + type = type.left(type.size() - 1); + } } } |