aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-04-07 10:13:03 +0200
committerUlf Hermann <ulf.hermann@qt.io>2021-04-09 09:26:25 +0200
commit0a07a6261263bb915c20539812146afd9005b64b (patch)
treea96d7940377176d8240dfb5b3842a3432c2e35e0
parentd62b56c4217a2610d9c7db84ffd3cde010ffae7c (diff)
Fix string type name in qmllint
The "length" property is special cased because it's the only own property of any JavaScript built-in type. As we've changed the internal name of the string type in builtins.qmltypes, we need to reflect this in qmllint. Fixes: QTBUG-92447 Change-Id: I9a5c7e9ab3da686bb6ac3fdffa36269abb0eb6ea Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit b28c8c87ec84dccc156603f8479fd0a8a06bc46c)
-rw-r--r--tests/auto/qml/qmllint/data/stringLength.qml9
-rw-r--r--tests/auto/qml/qmllint/tst_qmllint.cpp1
-rw-r--r--tools/qmllint/checkidentifiers.cpp2
3 files changed, 11 insertions, 1 deletions
diff --git a/tests/auto/qml/qmllint/data/stringLength.qml b/tests/auto/qml/qmllint/data/stringLength.qml
new file mode 100644
index 0000000000..354fed7b22
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/stringLength.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.15
+
+TextInput {
+ id: textInput
+
+ Component.onCompleted: {
+ console.log("text.length", textInput.text.length);
+ }
+}
diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp
index 9dd5679769..1a102fe81f 100644
--- a/tests/auto/qml/qmllint/tst_qmllint.cpp
+++ b/tests/auto/qml/qmllint/tst_qmllint.cpp
@@ -314,6 +314,7 @@ void TestQmllint::cleanQmlCode_data()
QTest::newRow("optionalImport") << QStringLiteral("optionalImport.qml");
QTest::newRow("goodAliasObject") << QStringLiteral("goodAliasObject.qml");
QTest::newRow("segFault") << QStringLiteral("SegFault.qml");
+ QTest::newRow("stringLength") << QStringLiteral("stringLength.qml");
}
void TestQmllint::cleanQmlCode()
diff --git a/tools/qmllint/checkidentifiers.cpp b/tools/qmllint/checkidentifiers.cpp
index 7e49a4fb4a..8b8a184b7d 100644
--- a/tools/qmllint/checkidentifiers.cpp
+++ b/tools/qmllint/checkidentifiers.cpp
@@ -160,7 +160,7 @@ bool CheckIdentifiers::checkMemberAccess(const QVector<FieldMember> &members,
continue;
}
- if (typeName == QLatin1String("string")) {
+ if (typeName == QLatin1String("QString")) {
detectedRestrictiveKind = typeName;
detectedRestrictiveName = access.m_name;
expectedNext.append(QLatin1String("length"));