QQmlProperty: fix signal handler warning

It should only be emitted if we find a signal of that name.

Pick-to: 6.5
Fixes: QTBUG-118710
Change-Id: I15cf92c03dd7b46805e5a69078ca2beb6c862293
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 9d10b79566)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 6c0489e65f)
This commit is contained in:
Fabian Kosmale 2023-11-02 11:06:14 +01:00 committed by Ulf Hermann
parent c753d52d8e
commit e5d8daf821
3 changed files with 30 additions and 6 deletions

View File

@ -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) {

View File

@ -0,0 +1,9 @@
import QtQml
QtObject {
id: root
property int onlineStatus
property Binding b: Binding {
root.onlineStatus: 12
}
}

View File

@ -222,6 +222,8 @@ private slots:
void invalidateQPropertyChangeTriggers();
void propertyStartsWithOn();
private:
QQmlEngine engine;
};
@ -2589,6 +2591,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"