diff options
Diffstat (limited to 'src/qml/qml/qqmlpropertycache.cpp')
-rw-r--r-- | src/qml/qml/qqmlpropertycache.cpp | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp index d368433949..e99c26cec8 100644 --- a/src/qml/qml/qqmlpropertycache.cpp +++ b/src/qml/qml/qqmlpropertycache.cpp @@ -352,6 +352,18 @@ QQmlPropertyCache::copyAndAppend(const QMetaObject *metaObject, return rv; } +static QHashedString signalNameToHandlerName(const QHashedString &methodName) +{ + return QQmlSignalNames::signalNameToHandlerName(methodName); +} + +static QHashedString signalNameToHandlerName(const QHashedCStringRef &methodName) +{ + return QQmlSignalNames::signalNameToHandlerName( + QLatin1StringView{ methodName.constData(), methodName.length() }); +} + + void QQmlPropertyCache::append(const QMetaObject *metaObject, QTypeRevision typeVersion, QQmlPropertyData::Flags propertyFlags, @@ -440,40 +452,29 @@ void QQmlPropertyCache::append(const QMetaObject *metaObject, QQmlPropertyData *old = nullptr; - if (utf8) { - QHashedString methodName(QString::fromUtf8(rawName, cptr - rawName)); + const auto doSetNamedProperty = [&](const auto &methodName) { if (StringCache::mapped_type *it = stringCache.value(methodName)) { if (handleOverride(methodName, data, (old = it->second)) == InvalidOverride) - continue; + return; } - setNamedProperty(methodName, ii, data); - if (data->isSignal()) { - QHashedString on(QQmlSignalNames::signalNameToHandlerName(methodName)); - setNamedProperty(on, ii, sigdata); - ++signalHandlerIndex; - } - } else { - QHashedCStringRef methodName(rawName, cptr - rawName); - if (StringCache::mapped_type *it = stringCache.value(methodName)) { - if (handleOverride(methodName, data, (old = it->second)) == InvalidOverride) - continue; - } setNamedProperty(methodName, ii, data); if (data->isSignal()) { - QHashedString on(QQmlSignalNames::signalNameToHandlerName( - QLatin1StringView{ methodName.constData(), methodName.length() })); - setNamedProperty(on, ii, data); + + // TODO: Remove this once we can. Signals should not be overridable. + if (!utf8) + data->m_flags.setIsOverridableSignal(true); + + setNamedProperty(signalNameToHandlerName(methodName), ii, sigdata); ++signalHandlerIndex; } - } + }; - if (old) { - // We only overload methods in the same class, exactly like C++ - if (old->isFunction() && old->coreIndex() >= methodOffset) - data->m_flags.setIsOverload(true); - } + if (utf8) + doSetNamedProperty(QHashedString(QString::fromUtf8(rawName, cptr - rawName))); + else + doSetNamedProperty(QHashedCStringRef(rawName, cptr - rawName)); } int propCount = metaObject->propertyCount(); |