diff options
author | Sami Shalayel <sami.shalayel@qt.io> | 2023-08-10 09:45:37 +0200 |
---|---|---|
committer | Sami Shalayel <sami.shalayel@qt.io> | 2023-08-15 12:13:31 +0000 |
commit | a1ce0596e517e84913b14ab23422137c95b8c785 (patch) | |
tree | a7a012aa8a0d260c6f464c6b5dc722806697fa4c /src/qml/qml/qqmlpropertyresolver.cpp | |
parent | 8d6f9e716d1c3fdd05ac14612583359313b9dc6e (diff) |
Replace signal name manipulations with QQmlSignalNames
Remove custom implementations found in qqmljs* and use the
static helper methods from qqmlsignalnames_p.h instead. This sometimes
requires to move some code around to avoid bugs with property that do
not have letters in their name.
Add a warning in the JS implementation of the SignalSpy.qml that the
used heuristic might fail on certain signal names.
Add tests in in tst_qqmllanguage to see if the property change handlers
work correctly for weird names.
Change-Id: I4dc73c34df7f77f529511fa04ab5fcc5385b59fc
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlpropertyresolver.cpp')
-rw-r--r-- | src/qml/qml/qqmlpropertyresolver.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/qml/qml/qqmlpropertyresolver.cpp b/src/qml/qml/qqmlpropertyresolver.cpp index ff29c38997..0217f7b7b5 100644 --- a/src/qml/qml/qqmlpropertyresolver.cpp +++ b/src/qml/qml/qqmlpropertyresolver.cpp @@ -3,6 +3,7 @@ #include "qqmlpropertyresolver_p.h" #include <private/qqmlcontextdata_p.h> +#include <private/qqmlsignalnames_p.h> QT_BEGIN_NAMESPACE @@ -43,10 +44,8 @@ const QQmlPropertyData *QQmlPropertyResolver::signal(const QString &name, bool * return d; } - if (name.endsWith(QLatin1String("Changed"))) { - QString propName = name.mid(0, name.size() - static_cast<int>(strlen("Changed"))); - - d = property(propName, notInRevision); + if (auto propName = QQmlSignalNames::changedSignalNameToPropertyName(name)) { + d = property(*propName, notInRevision); if (d) return cache->signal(d->notifyIndex()); } |