aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2023-11-02 11:06:14 +0100
committerUlf Hermann <ulf.hermann@qt.io>2024-01-30 17:14:09 +0100
commit9d10b7956662d56e02053b3cbe41fd7ca05dced3 (patch)
treeb3b6be5fd33cc036c21eed952df8d4233ebf9370
parent37ef144704c09e23fd2edfd49daf86b368147d15 (diff)
QQmlProperty: fix signal handler warning
It should only be emitted if we find a signal of that name. Pick-to: 6.7 6.6 6.5 Fixes: QTBUG-118710 Change-Id: I15cf92c03dd7b46805e5a69078ca2beb6c862293 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--src/qml/qml/qqmlproperty.cpp13
-rw-r--r--tests/auto/qml/qqmlproperty/data/propertyStartsWithOn.qml9
-rw-r--r--tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp14
3 files changed, 30 insertions, 6 deletions
diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp
index bdeb478a9b..a66704cb4a 100644
--- a/src/qml/qml/qqmlproperty.cpp
+++ b/src/qml/qml/qqmlproperty.cpp
@@ -411,13 +411,14 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name,
} else {
signalName = QQmlSignalNames::badHandlerNameToSignalName(terminal);
if (signalName) {
- qWarning()
- << terminal
- << "is not a properly capitalized signal handler name."
- << QQmlSignalNames::signalNameToHandlerName(*signalName)
- << "would be correct.";
- if (findSignal(*signalName))
+ if (findSignal(*signalName)) {
+ qWarning()
+ << terminal
+ << "is not a properly capitalized signal handler name."
+ << QQmlSignalNames::signalNameToHandlerName(*signalName)
+ << "would be correct.";
return;
+ }
}
}
diff --git a/tests/auto/qml/qqmlproperty/data/propertyStartsWithOn.qml b/tests/auto/qml/qqmlproperty/data/propertyStartsWithOn.qml
new file mode 100644
index 0000000000..0ced54a9ca
--- /dev/null
+++ b/tests/auto/qml/qqmlproperty/data/propertyStartsWithOn.qml
@@ -0,0 +1,9 @@
+import QtQml
+
+QtObject {
+ id: root
+ property int onlineStatus
+ property Binding b: Binding {
+ root.onlineStatus: 12
+ }
+}
diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
index d833c16d77..05802a88d5 100644
--- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
+++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
@@ -222,6 +222,8 @@ private slots:
void invalidateQPropertyChangeTriggers();
+ void propertyStartsWithOn();
+
private:
QQmlEngine engine;
};
@@ -2590,6 +2592,18 @@ void tst_qqmlproperty::invalidateQPropertyChangeTriggers()
}));
}
+void tst_qqmlproperty::propertyStartsWithOn()
+{
+ QTest::failOnWarning("\"onlineStatus\" is not a properly capitalized signal handler name. "
+ "\"onLineStatus\" would be correct.");
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("propertyStartsWithOn.qml"));
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+ QScopedPointer<QObject> root(component.create());
+ QVERIFY(!root.isNull());
+ QCOMPARE(root->property("onlineStatus").toInt(), 12);
+}
+
QTEST_MAIN(tst_qqmlproperty)
#include "tst_qqmlproperty.moc"