diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-02-28 16:01:53 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-02 22:29:51 +0100 |
commit | ac57f185d1a2203cd4b585df7bd7af01c3ec33ed (patch) | |
tree | 8e6d9a9c256db1e9f10e3bc0ef4f4d546ae6fcdb /src/qml/jsruntime | |
parent | b92b339705c9075a4b1b05b1b470827915dfe50d (diff) |
Fix calls to overloaded slots for QObjects not created by QML
If we don't have a property cache, we need to fall back to a slower method of
determining the overload methods. We have the code for that in RelatedMethod,
once we determine that we're calling overloads, but we never hit that code path
because we did not _initially_ determine that the method was an overload.
Task-number: QTBUG-37157
Change-Id: I8ff39156e5668236b3797400b4086ed545624398
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 14533946e1..cd19520f9f 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -1810,10 +1810,24 @@ ReturnedValue QObjectMethod::callInternal(CallData *callData) } if (method.coreIndex == -1) { - method.load(object->metaObject()->method(m_index)); + const QMetaObject *mo = object->metaObject(); + const QMetaMethod moMethod = mo->method(m_index); + method.load(moMethod); if (method.coreIndex == -1) return QV4::Encode::undefined(); + + // Look for overloaded methods + QByteArray methodName = moMethod.name(); + const int methodOffset = mo->methodOffset(); + for (int ii = m_index - 1; ii >= methodOffset; --ii) { + if (methodName == mo->method(ii).name()) { + method.setFlags(method.getFlags() | QQmlPropertyData::IsOverload); + method.overrideIndexIsProperty = 0; + method.overrideIndex = ii; + break; + } + } } if (method.isV4Function()) { |