aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2022-04-27 17:53:52 +0200
committerMaximilian Goldstein <max.goldstein@qt.io>2022-04-28 15:55:03 +0200
commit7dd6fbb51a90803d51ce286529f6d351ebf77dfc (patch)
treed3042a81d7ca13dfcb9ebc4b4e0b1d600debf928
parent4b330fa07b01b4ad8051a97af7c04d9a9a574b95 (diff)
QmlLintQuickPlugin: Remove redundant anchors null warning
Previously we warned when an anchor was null again after already displaying a generic warning about a type mismatch. This is redundant, so let's stick with the generic one. Change-Id: I8f43d279b712d728dc154f48286b8d5c0dac9976 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--src/plugins/qmllint/quick/quicklintplugin.cpp6
-rw-r--r--tests/auto/qml/qmllint/data/pluginQuick_anchors.qml4
-rw-r--r--tests/auto/qml/qmllint/tst_qmllint.cpp12
3 files changed, 10 insertions, 12 deletions
diff --git a/src/plugins/qmllint/quick/quicklintplugin.cpp b/src/plugins/qmllint/quick/quicklintplugin.cpp
index b2248d3896..6e2d1e7382 100644
--- a/src/plugins/qmllint/quick/quicklintplugin.cpp
+++ b/src/plugins/qmllint/quick/quicklintplugin.cpp
@@ -255,12 +255,6 @@ void AnchorsValidatorPass::run(const QQmlSA::Element &element)
bottom = srcLoc;
else if (propertyName == u"baseline")
baseline = srcLoc;
-
- if (propertyName == u"horizontalCenter" || propertyName == u"verticalCenter") {
- if (groupBinding.bindingType() == QQmlJSMetaPropertyBinding::Null) {
- emitWarning("Cannot anchor to a null item.", srcLoc);
- }
- }
}
}
diff --git a/tests/auto/qml/qmllint/data/pluginQuick_anchors.qml b/tests/auto/qml/qmllint/data/pluginQuick_anchors.qml
index ddfa163479..ea98b76663 100644
--- a/tests/auto/qml/qmllint/data/pluginQuick_anchors.qml
+++ b/tests/auto/qml/qmllint/data/pluginQuick_anchors.qml
@@ -2,10 +2,10 @@ import QtQuick
Item {
Item {
- anchors.horizontalCenter: parent.horizontalCenter
+ anchors.horizontalCenter: null
anchors.left: parent.left
anchors.right: parent.right
- anchors.verticalCenter: parent.verticalCenter
+ anchors.verticalCenter: null
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.baseline: parent.baseline
diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp
index 6110ee5448..492ec95350 100644
--- a/tests/auto/qml/qmllint/tst_qmllint.cpp
+++ b/tests/auto/qml/qmllint/tst_qmllint.cpp
@@ -37,6 +37,8 @@
Q_IMPORT_PLUGIN(LintPlugin)
+using namespace Qt::StringLiterals;
+
class TestQmllint: public QQmlDataTest
{
Q_OBJECT
@@ -1664,13 +1666,15 @@ void TestQmllint::quickPlugin()
QVERIFY(pluginFound);
runTest("pluginQuick_anchors.qml",
- Result {
- { Message {
+ Result{ { Message{
u"Cannot specify left, right, and horizontalCenter anchors at the same time."_qs },
Message {
u"Cannot specify top, bottom, and verticalCenter anchors at the same time."_qs },
- Message {
- u"Baseline anchor cannot be used in conjunction with top, bottom, or verticalCenter anchors."_qs } } });
+ Message{
+ u"Baseline anchor cannot be used in conjunction with top, bottom, or verticalCenter anchors."_qs },
+ Message{ u"Cannot assign binding of type null to QQuickAnchorLine"_s, 5, 35 },
+ Message{ u"Cannot assign binding of type null to QQuickAnchorLine"_s, 8,
+ 33 } } });
runTest("pluginQuick_layoutChildren.qml",
Result {
{ Message {