diff options
| author | Fabian Kosmale <fabian.kosmale@qt.io> | 2023-11-02 11:06:14 +0100 |
|---|---|---|
| committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2024-02-01 18:30:23 +0000 |
| commit | 4bc9083a78b203a47dfad276e326c2743c4f537e (patch) | |
| tree | b5c9cb1f5c71162c67e878287d1fb8df00773f69 | |
| parent | 16a0bea0314a48ad1b0fc0bc1b9dcdd0099e4d8e (diff) | |
QQmlProperty: fix signal handler warning
It should only be emitted if we find a signal of that name.
Fixes: QTBUG-118710
Change-Id: I15cf92c03dd7b46805e5a69078ca2beb6c862293
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 9d10b7956662d56e02053b3cbe41fd7ca05dced3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 6c0489e65f4edbfce7448b3ca8e943c84b9456f4)
(cherry picked from commit e5d8daf8212cabfd081ef8300013441f42f69533)
| -rw-r--r-- | src/qml/qml/qqmlproperty.cpp | 13 | ||||
| -rw-r--r-- | tests/auto/qml/qqmlproperty/data/propertyStartsWithOn.qml | 9 | ||||
| -rw-r--r-- | tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp | 14 |
3 files changed, 30 insertions, 6 deletions
diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index 3391bc28fe..8f7538dfa7 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -428,13 +428,14 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name, if (result != end) *result = result->toUpper(); - qWarning() - << terminalString - << "is not a properly capitalized signal handler name." - << handlerName - << "would be correct."; - if (findSignalInMetaObject(signalName.toUtf8())) + if (findSignalInMetaObject(signalName.toUtf8())) { + qWarning() + << terminalString + << "is not a properly capitalized signal handler name." + << handlerName + << "would be correct."; return; + } } if (ddata && ddata->propertyCache) { 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 3b5d48df1b..235de5f406 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -220,6 +220,8 @@ private slots: void invalidateQPropertyChangeTriggers(); + void propertyStartsWithOn(); + private: QQmlEngine engine; }; @@ -2574,6 +2576,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" |
