From 4dd4c442e15a155ff3784f28d6c1ebc68fe8382e Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Mon, 5 Mar 2012 08:31:00 +0100 Subject: [PATCH] Adapt to Qt5 meta-object changes QMetaMethod::signature() has been renamed to methodSignature(), and it now returns a QByteArray. Also, the new function QMetaMethod::isValid() should be used to determine whether a method is valid, instead of relying on signature() returning a 0 pointer. Where it makes sense, the existing code that was using signature() and parameterTypes() has been changed to use the new API QMetaMethod::name(), parameterCount(), and parameterType(int). Also, in the new meta-object revision (7), the QMetaObject stringdata member is now of type QByteArrayData*. QFastMetaBuilder will be ported to generate the new format, but for now it's sufficient to reinterpret_cast the stringdata assignment to keep it compiling. Change-Id: Ie340ef17bcebc3afa4aae6450dfe2d06e4d881a4 Reviewed-by: Aaron Kennedy --- src/qml/debugger/qqmlenginedebugservice.cpp | 6 +- src/qml/qml/ftw/qfastmetabuilder.cpp | 2 +- src/qml/qml/qqmlboundsignal.cpp | 4 +- src/qml/qml/qqmlmetatype.cpp | 9 +-- src/qml/qml/qqmlproperty.cpp | 9 +-- src/qml/qml/qqmlpropertycache.cpp | 79 ++++++++++------------ src/qml/qml/qqmlvme.cpp | 9 ++- src/qml/qml/qqmlvmemetaobject.cpp | 2 +- src/qml/qml/v8/qv8qobjectwrapper.cpp | 16 +---- src/quick/items/qquickshadereffect.cpp | 4 +- src/quick/particles/qquickcustomparticle.cpp | 4 +- .../auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp | 4 +- tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp | 26 +++---- tests/auto/quick/qquickstates/tst_qquickstates.cpp | 2 +- tools/qmlplugindump/main.cpp | 15 ++-- 15 files changed, 82 insertions(+), 109 deletions(-) diff --git a/src/qml/debugger/qqmlenginedebugservice.cpp b/src/qml/debugger/qqmlenginedebugservice.cpp index 114d7ef..76a8802 100644 --- a/src/qml/debugger/qqmlenginedebugservice.cpp +++ b/src/qml/debugger/qqmlenginedebugservice.cpp @@ -247,10 +247,8 @@ void QQmlEngineDebugService::buildObjectDump(QDataStream &message, prop.value = expr->expression(); QObject *scope = expr->scopeObject(); if (scope) { - QString sig = QLatin1String(scope->metaObject()->method(signal->index()).signature()); - int lparen = sig.indexOf(QLatin1Char('(')); - if (lparen >= 0) { - QString methodName = sig.mid(0, lparen); + QString methodName = QLatin1String(scope->metaObject()->method(signal->index()).name().constData()); + if (!methodName.isEmpty()) { prop.name = QLatin1String("on") + methodName[0].toUpper() + methodName.mid(1); } diff --git a/src/qml/qml/ftw/qfastmetabuilder.cpp b/src/qml/qml/ftw/qfastmetabuilder.cpp index 08ea76b..00685f8 100644 --- a/src/qml/qml/ftw/qfastmetabuilder.cpp +++ b/src/qml/qml/ftw/qfastmetabuilder.cpp @@ -306,7 +306,7 @@ void QFastMetaBuilder::allocateStringData() void QFastMetaBuilder::fromData(QMetaObject *output, const QMetaObject *parent, const QByteArray &data) { output->d.superdata = parent; - output->d.stringdata = data.constData() + header(data)->fieldCount * sizeof(uint); + output->d.stringdata = reinterpret_cast(data.constData() + header(data)->fieldCount * sizeof(uint)); output->d.data = fieldPointer(data); output->d.extradata = 0; } diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index ca6b13e..02f4941 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -172,11 +172,11 @@ int QQmlBoundSignal::qt_metacall(QMetaObject::Call c, int id, void **a) return -1; if (QQmlDebugService::isDebuggingEnabled()) - QV8DebugService::instance()->signalEmitted(QString::fromAscii(m_signal.signature())); + QV8DebugService::instance()->signalEmitted(QString::fromAscii(m_signal.methodSignature().constData())); QQmlHandlingSignalProfiler prof; if (prof.enabled) { - prof.setSignalInfo(QString::fromLatin1(m_signal.signature()), + prof.setSignalInfo(QString::fromLatin1(m_signal.methodSignature().constData()), m_expression->expression()); prof.setLocation(m_expression->sourceFile(), m_expression->lineNumber(), m_expression->columnNumber()); diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index 2061530..5b80f57 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -340,9 +340,7 @@ static void clone(QMetaObjectBuilder &builder, const QMetaObject *mo, QMetaMethod method = mo->method(ii); // More complex - need to search name - QByteArray name = method.signature(); - int parenIdx = name.indexOf('('); - if (parenIdx != -1) name = name.left(parenIdx); + QByteArray name = method.name(); bool found = false; @@ -352,11 +350,8 @@ static void clone(QMetaObjectBuilder &builder, const QMetaObject *mo, ++ii) { QMetaMethod other = ignoreEnd->method(ii); - QByteArray othername = other.signature(); - int parenIdx = othername.indexOf('('); - if (parenIdx != -1) othername = othername.left(parenIdx); - found = name == othername; + found = name == other.name(); } QMetaMethodBuilder m = builder.addMethod(method); diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index 00cb65d..86e1822 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -333,7 +333,7 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name) signalName[0] = signalName.at(0).toLower(); QMetaMethod method = findSignalByName(currentObject->metaObject(), signalName.toLatin1().constData()); - if (method.signature()) { + if (method.isValid()) { object = currentObject; core.load(method); return; @@ -1707,7 +1707,7 @@ bool QQmlProperty::connectNotifySignal(QObject *dest, const char *slot) const QMetaProperty prop = d->object->metaObject()->property(d->core.coreIndex); if (prop.hasNotifySignal()) { - QByteArray signal(QByteArray("2") + prop.notifySignal().signature()); + QByteArray signal(QByteArray("2") + prop.notifySignal().methodSignature()); return QObject::connect(d->object, signal.constData(), dest, slot); } else { return false; @@ -1813,11 +1813,8 @@ QMetaMethod QQmlPropertyPrivate::findSignalByName(const QMetaObject *mo, const Q int methods = mo->methodCount(); for (int ii = methods - 1; ii >= 2; --ii) { // >= 2 to block the destroyed signal QMetaMethod method = mo->method(ii); - QByteArray methodName = method.signature(); - int idx = methodName.indexOf('('); - methodName = methodName.left(idx); - if (methodName == name) + if (method.name() == name) return method; } diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp index 93c6aa1..af6cd92 100644 --- a/src/qml/qml/qqmlpropertycache.cpp +++ b/src/qml/qml/qqmlpropertycache.cpp @@ -176,19 +176,11 @@ void QQmlPropertyData::load(const QMetaMethod &m) flags |= IsFunction; if (m.methodType() == QMetaMethod::Signal) flags |= IsSignal; - propType = QVariant::Invalid; - - const char *returnType = m.typeName(); - if (returnType) - propType = QMetaType::type(returnType); + propType = m.returnType(); - const char *signature = m.signature(); - while (*signature != '(') { Q_ASSERT(*signature != 0); ++signature; } - - ++signature; - if (*signature != ')') { + if (m.parameterCount()) { flags |= HasArguments; - if (0 == ::strcmp(signature, "QQmlV8Function*)")) { + if ((m.parameterCount() == 1) && (m.parameterTypes().first() == "QQmlV8Function*")) { flags |= IsV8Function; } } @@ -212,13 +204,9 @@ void QQmlPropertyData::lazyLoad(const QMetaMethod &m) flags |= NotFullyResolved; } - const char *signature = m.signature(); - while (*signature != '(') { Q_ASSERT(*signature != 0); ++signature; } - - ++signature; - if (*signature != ')') { + if (m.parameterCount()) { flags |= HasArguments; - if (0 == ::strcmp(signature, "QQmlV8Function*)")) { + if ((m.parameterCount() == 1) && (m.parameterTypes().first() == "QQmlV8Function*")) { flags |= IsV8Function; } } @@ -414,10 +402,17 @@ void QQmlPropertyCache::append(QQmlEngine *engine, const QMetaObject *metaObject continue; // Extract method name - const char *signature = m.signature(); + const char *signature; + if (QMetaObjectPrivate::get(metaObject)->revision >= 7) { + // Safe to use the raw name pointer + signature = m.name().constData(); + } else { + // Safe to use the raw signature pointer + signature = m.methodSignature().constData(); + } const char *cptr = signature; char utf8 = 0; - while (*cptr != '(') { + while (*cptr && *cptr != '(') { Q_ASSERT(*cptr != 0); utf8 |= *cptr & 0x80; ++cptr; @@ -663,11 +658,7 @@ QString QQmlPropertyData::name(const QMetaObject *metaObject) if (flags & IsFunction) { QMetaMethod m = metaObject->method(coreIndex); - QString name = QString::fromUtf8(m.signature()); - int parenIdx = name.indexOf(QLatin1Char('(')); - if (parenIdx != -1) - name = name.left(parenIdx); - return name; + return QString::fromUtf8(m.name().constData()); } else { QMetaProperty p = metaObject->property(coreIndex); return QString::fromUtf8(p.name()); @@ -727,15 +718,19 @@ int *QQmlPropertyCache::methodParameterTypes(QObject *object, int index, const QMetaObject *metaObject = object->metaObject(); QMetaMethod m = metaObject->method(index); - QList argTypeNames = m.parameterTypes(); - A *args = static_cast(malloc(sizeof(A) + (argTypeNames.count() + 1) * sizeof(int))); - args->arguments[0] = argTypeNames.count(); + int argc = m.parameterCount(); + A *args = static_cast(malloc(sizeof(A) + (argc + 1) * sizeof(int))); + args->arguments[0] = argc; + QList argTypeNames; // Only loaded if needed - for (int ii = 0; ii < argTypeNames.count(); ++ii) { - int type = QMetaType::type(argTypeNames.at(ii)); - if (type == QVariant::Invalid) + for (int ii = 0; ii < argc; ++ii) { + int type = m.parameterType(ii); + if (type == QVariant::Invalid) { + if (argTypeNames.isEmpty()) + argTypeNames = m.parameterTypes(); type = EnumType(object->metaObject(), argTypeNames.at(ii)); + } if (type == QVariant::Invalid) { if (unknownTypeError) *unknownTypeError = argTypeNames.at(ii); free(args); @@ -751,14 +746,18 @@ int *QQmlPropertyCache::methodParameterTypes(QObject *object, int index, } else { QMetaMethod m = object->metaObject()->method(index); - QList argTypeNames = m.parameterTypes(); - dummy.resize(argTypeNames.count() + 1); - dummy[0] = argTypeNames.count(); + int argc = m.parameterCount(); + dummy.resize(argc + 1); + dummy[0] = argc; + QList argTypeNames; // Only loaded if needed - for (int ii = 0; ii < argTypeNames.count(); ++ii) { - int type = QMetaType::type(argTypeNames.at(ii)); - if (type == QVariant::Invalid) + for (int ii = 0; ii < argc; ++ii) { + int type = m.parameterType(ii); + if (type == QVariant::Invalid) { + if (argTypeNames.isEmpty()) + argTypeNames = m.parameterTypes(); type = EnumType(object->metaObject(), argTypeNames.at(ii)); + } if (type == QVariant::Invalid) { if (unknownTypeError) *unknownTypeError = argTypeNames.at(ii); return 0; @@ -804,13 +803,9 @@ QQmlPropertyData qQmlPropertyCacheCreate(const QMetaObject *metaObject, QMetaMethod m = metaObject->method(ii); if (m.access() == QMetaMethod::Private) continue; - QString methodName = QString::fromUtf8(m.signature()); - - int parenIdx = methodName.indexOf(QLatin1Char('(')); - Q_ASSERT(parenIdx != -1); - QStringRef methodNameRef = methodName.leftRef(parenIdx); + QString methodName = QString::fromUtf8(m.name().constData()); - if (methodNameRef == property) { + if (methodName == property) { rv.load(m); return rv; } diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp index 2b66e00..9ef9ca9 100644 --- a/src/qml/qml/qqmlvme.cpp +++ b/src/qml/qml/qqmlvme.cpp @@ -690,11 +690,14 @@ QObject *QQmlVME::run(QList *errors, if (prop.type() & QQmlProperty::SignalProperty) { QMetaMethod method = QQmlMetaType::defaultMethod(assign); - if (method.signature() == 0) + if (!method.isValid()) VME_EXCEPTION(tr("Cannot assign object type %1 with no default method").arg(QString::fromLatin1(assign->metaObject()->className())), instr.line); - if (!QMetaObject::checkConnectArgs(prop.method().signature(), method.signature())) - VME_EXCEPTION(tr("Cannot connect mismatched signal/slot %1 %vs. %2").arg(QString::fromLatin1(method.signature())).arg(QString::fromLatin1(prop.method().signature())), instr.line); + if (!QMetaObject::checkConnectArgs(prop.method(), method)) { + VME_EXCEPTION(tr("Cannot connect mismatched signal/slot %1 %vs. %2") + .arg(QString::fromLatin1(method.methodSignature().constData())) + .arg(QString::fromLatin1(prop.method().methodSignature().constData())), instr.line); + } QQmlPropertyPrivate::connect(target, prop.index(), assign, method.methodIndex()); diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp index 7ea89a4..a7af2db 100644 --- a/src/qml/qml/qqmlvmemetaobject.cpp +++ b/src/qml/qml/qqmlvmemetaobject.cpp @@ -738,7 +738,7 @@ int QQmlVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a) // performance reasons; see QTBUG-24064) and thus compilation will have failed. QQmlError e; e.setDescription(QString(QLatin1String("Exception occurred during compilation of function: %1")). - arg(QLatin1String(QMetaObject::method(_id).signature()))); + arg(QLatin1String(QMetaObject::method(_id).methodSignature().constData()))); ep->warning(e); return -1; // The dynamic method with that id is not available. } diff --git a/src/qml/qml/v8/qv8qobjectwrapper.cpp b/src/qml/qml/v8/qv8qobjectwrapper.cpp index 4be93d1..d61ca8b 100644 --- a/src/qml/qml/v8/qv8qobjectwrapper.cpp +++ b/src/qml/qml/v8/qv8qobjectwrapper.cpp @@ -1673,16 +1673,6 @@ static inline int QMetaObject_methods(const QMetaObject *metaObject) return reinterpret_cast(metaObject->d.data)->methodCount; } -static QByteArray QMetaMethod_name(const QMetaMethod &m) -{ - QByteArray sig = m.signature(); - int paren = sig.indexOf('('); - if (paren == -1) - return sig; - else - return sig.left(paren); -} - /*! Returns the next related method, if one, or 0. */ @@ -1711,9 +1701,9 @@ static const QQmlPropertyData * RelatedMethod(QObject *object, dummy.load(method); // Look for overloaded methods - QByteArray methodName = QMetaMethod_name(method); + QByteArray methodName = method.name(); for (int ii = current->overrideIndex - 1; ii >= methodOffset; --ii) { - if (methodName == QMetaMethod_name(mo->method(ii))) { + if (methodName == mo->method(ii).name()) { dummy.setFlags(dummy.getFlags() | QQmlPropertyData::IsOverload); dummy.overrideIndexIsProperty = 0; dummy.overrideIndex = ii; @@ -1827,7 +1817,7 @@ static v8::Handle CallOverloaded(QObject *object, const QQmlPropertyD const QQmlPropertyData *candidate = &data; while (candidate) { error += QLatin1String("\n ") + - QString::fromUtf8(object->metaObject()->method(candidate->coreIndex).signature()); + QString::fromUtf8(object->metaObject()->method(candidate->coreIndex).methodSignature().constData()); candidate = RelatedMethod(object, candidate, dummy); } diff --git a/src/quick/items/qquickshadereffect.cpp b/src/quick/items/qquickshadereffect.cpp index 3024c31..e66e05a 100644 --- a/src/quick/items/qquickshadereffect.cpp +++ b/src/quick/items/qquickshadereffect.cpp @@ -458,7 +458,7 @@ void QQuickShaderEffect::connectPropertySignals() if (!mp.hasNotifySignal()) qWarning("QQuickShaderEffect: property '%s' does not have notification method!", it->constData()); QByteArray signalName("2"); - signalName.append(mp.notifySignal().signature()); + signalName.append(mp.notifySignal().methodSignature()); connect(this, signalName, this, SLOT(updateData())); } else { // If the source is set via a dynamic property, like the layer is, then we need this check @@ -474,7 +474,7 @@ void QQuickShaderEffect::connectPropertySignals() if (pi >= 0) { QMetaProperty mp = metaObject()->property(pi); QByteArray signalName("2"); - signalName.append(mp.notifySignal().signature()); + signalName.append(mp.notifySignal().methodSignature()); connect(this, signalName, source.mapper, SLOT(map())); source.mapper->setMapping(this, i); connect(source.mapper, SIGNAL(mapped(int)), this, SLOT(changeSource(int))); diff --git a/src/quick/particles/qquickcustomparticle.cpp b/src/quick/particles/qquickcustomparticle.cpp index 3647e5b..a8f146a 100644 --- a/src/quick/particles/qquickcustomparticle.cpp +++ b/src/quick/particles/qquickcustomparticle.cpp @@ -314,7 +314,7 @@ void QQuickCustomParticle::connectPropertySignals() if (!mp.hasNotifySignal()) qWarning("QQuickCustomParticle: property '%s' does not have notification method!", it->constData()); QByteArray signalName("2"); - signalName.append(mp.notifySignal().signature()); + signalName.append(mp.notifySignal().methodSignature()); connect(this, signalName, this, SLOT(updateData())); } else { qWarning("QQuickCustomParticle: '%s' does not have a matching property!", it->constData()); @@ -326,7 +326,7 @@ void QQuickCustomParticle::connectPropertySignals() if (pi >= 0) { QMetaProperty mp = metaObject()->property(pi); QByteArray signalName("2"); - signalName.append(mp.notifySignal().signature()); + signalName.append(mp.notifySignal().methodSignature()); connect(this, signalName, source.mapper, SLOT(map())); source.mapper->setMapping(this, i); connect(source.mapper, SIGNAL(mapped(int)), this, SLOT(changeSource(int))); diff --git a/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp b/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp index f2c50dd..8876524 100644 --- a/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp +++ b/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp @@ -244,7 +244,7 @@ void tst_QQmlMetaObject::property() QVERIFY(prop.notifySignalIndex() != -1); QMetaMethod signal = prop.notifySignal(); QCOMPARE(signal.methodType(), QMetaMethod::Signal); - QCOMPARE(signal.signature(), "testChanged()"); + QCOMPARE(signal.methodSignature(), QByteArray("testChanged()")); QCOMPARE(signal.access(), QMetaMethod::Protected); QCOMPARE(signal.parameterTypes(), QList()); QCOMPARE(signal.parameterNames(), QList()); @@ -361,7 +361,7 @@ void tst_QQmlMetaObject::method() QMetaMethod method = mo->method(mo->methodOffset()); QCOMPARE(method.methodType(), methodType); - QCOMPARE(QString::fromUtf8(method.signature()), signature); + QCOMPARE(QString::fromUtf8(method.methodSignature().constData()), signature); QCOMPARE(method.access(), QMetaMethod::Protected); QCOMPARE(method.parameterTypes(), parameterTypeNames); QCOMPARE(method.parameterNames(), parameterNames); diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp index 13ea1ab..10b9b83 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -161,7 +161,7 @@ void tst_qqmlproperty::qmlmetaproperty() QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, -1), false); - QVERIFY(prop.method().signature() == 0); + QVERIFY(!prop.method().isValid()); QCOMPARE(prop.type(), QQmlProperty::Invalid); QCOMPARE(prop.isProperty(), false); QCOMPARE(prop.isWritable(), false); @@ -264,7 +264,7 @@ void tst_qqmlproperty::qmlmetaproperty_object() QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, -1), false); - QVERIFY(prop.method().signature() == 0); + QVERIFY(!prop.method().isValid()); QCOMPARE(prop.type(), QQmlProperty::Invalid); QCOMPARE(prop.isProperty(), false); QCOMPARE(prop.isWritable(), false); @@ -311,7 +311,7 @@ void tst_qqmlproperty::qmlmetaproperty_object() QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, -1), false); - QVERIFY(prop.method().signature() == 0); + QVERIFY(!prop.method().isValid()); QCOMPARE(prop.type(), QQmlProperty::Property); QCOMPARE(prop.isProperty(), true); QCOMPARE(prop.isWritable(), false); @@ -365,7 +365,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, -1), false); - QVERIFY(prop.method().signature() == 0); + QVERIFY(!prop.method().isValid()); QCOMPARE(prop.type(), QQmlProperty::Invalid); QCOMPARE(prop.isProperty(), false); QCOMPARE(prop.isWritable(), false); @@ -412,7 +412,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, -1), false); - QVERIFY(prop.method().signature() == 0); + QVERIFY(!prop.method().isValid()); QCOMPARE(prop.type(), QQmlProperty::Property); QCOMPARE(prop.isProperty(), true); QCOMPARE(prop.isWritable(), false); @@ -461,7 +461,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, -1), false); - QCOMPARE(QString(prop.method().signature()), QString("clicked()")); + QCOMPARE(QString(prop.method().methodSignature()), QString("clicked()")); QCOMPARE(prop.type(), QQmlProperty::SignalProperty); QCOMPARE(prop.isProperty(), false); QCOMPARE(prop.isWritable(), false); @@ -509,7 +509,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, -1), false); - QCOMPARE(QString(prop.method().signature()), QString("oddlyNamedNotifySignal()")); + QCOMPARE(QString(prop.method().methodSignature()), QString("oddlyNamedNotifySignal()")); QCOMPARE(prop.type(), QQmlProperty::SignalProperty); QCOMPARE(prop.isProperty(), false); QCOMPARE(prop.isWritable(), false); @@ -562,7 +562,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_context() QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, -1), false); - QVERIFY(prop.method().signature() == 0); + QVERIFY(!prop.method().isValid()); QCOMPARE(prop.type(), QQmlProperty::Invalid); QCOMPARE(prop.isProperty(), false); QCOMPARE(prop.isWritable(), false); @@ -609,7 +609,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_context() QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, -1), false); - QVERIFY(prop.method().signature() == 0); + QVERIFY(!prop.method().isValid()); QCOMPARE(prop.type(), QQmlProperty::Property); QCOMPARE(prop.isProperty(), true); QCOMPARE(prop.isWritable(), false); @@ -663,7 +663,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, -1), false); - QVERIFY(prop.method().signature() == 0); + QVERIFY(!prop.method().isValid()); QCOMPARE(prop.type(), QQmlProperty::Invalid); QCOMPARE(prop.isProperty(), false); QCOMPARE(prop.isWritable(), false); @@ -710,7 +710,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, -1), false); - QVERIFY(prop.method().signature() == 0); + QVERIFY(!prop.method().isValid()); QCOMPARE(prop.type(), QQmlProperty::Property); QCOMPARE(prop.isProperty(), true); QCOMPARE(prop.isWritable(), false); @@ -759,7 +759,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, -1), false); - QCOMPARE(QString(prop.method().signature()), QString("clicked()")); + QCOMPARE(QString(prop.method().methodSignature()), QString("clicked()")); QCOMPARE(prop.type(), QQmlProperty::SignalProperty); QCOMPARE(prop.isProperty(), false); QCOMPARE(prop.isWritable(), false); @@ -807,7 +807,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifySignal(obj, -1), false); - QCOMPARE(QString(prop.method().signature()), QString("oddlyNamedNotifySignal()")); + QCOMPARE(QString(prop.method().methodSignature()), QString("oddlyNamedNotifySignal()")); QCOMPARE(prop.type(), QQmlProperty::SignalProperty); QCOMPARE(prop.isProperty(), false); QCOMPARE(prop.isWritable(), false); diff --git a/tests/auto/quick/qquickstates/tst_qquickstates.cpp b/tests/auto/quick/qquickstates/tst_qquickstates.cpp index fc8194f..7fd8fc4 100644 --- a/tests/auto/quick/qquickstates/tst_qquickstates.cpp +++ b/tests/auto/quick/qquickstates/tst_qquickstates.cpp @@ -245,7 +245,7 @@ void tst_qquickstates::basicChanges() QMetaProperty prop = rect->metaObject()->property(rect->metaObject()->indexOfProperty("propertyWithNotify")); QVERIFY(prop.hasNotifySignal()); - QString notifySignal = QByteArray(prop.notifySignal().signature()); + QString notifySignal = prop.notifySignal().methodSignature(); QVERIFY(!notifySignal.startsWith("propertyWithNotifyChanged(")); QCOMPARE(rect->color(), QColor(Qt::red)); diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index cea2915..b3cc721 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -386,10 +386,10 @@ public: // for QObject, hide deleteLater() and onDestroyed for (int index = meta->methodOffset(); index < meta->methodCount(); ++index) { QMetaMethod method = meta->method(index); - const char *signature(method.signature()); - if (signature == QLatin1String("destroyed(QObject*)") - || signature == QLatin1String("destroyed()") - || signature == QLatin1String("deleteLater()")) + QByteArray signature = method.methodSignature(); + if (signature == QByteArrayLiteral("destroyed(QObject*)") + || signature == QByteArrayLiteral("destroyed()") + || signature == QByteArrayLiteral("deleteLater()")) continue; dump(method, implicitSignals); } @@ -500,12 +500,7 @@ private: return; // nothing to do. } - QByteArray name = meth.signature(); - int lparenIndex = name.indexOf('('); - if (lparenIndex == -1) { - return; // invalid signature - } - name = name.left(lparenIndex); + QByteArray name = meth.name(); const QString typeName = convertToId(meth.typeName()); if (implicitSignals.contains(name) -- 2.7.4