diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-08-04 10:35:46 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-08-24 00:19:05 +0200 |
commit | 1697fbdf05ff643d617a9ba1614454926e86a3d9 (patch) | |
tree | 1c090fd9254ccedf33e724158e115157998304cf /src/dbus | |
parent | 92b37676328a960bc092b1f3834233c550376457 (diff) |
Deprecate the static int based API in QMetaType
And remove one of the type id to name mapping that still
existed in QMetaType. QMetaTypeInterface can provide that,
so there's no need to have a second copy of the data.
qMetaTypeTypeInternal() can still map all the names of all
builtin types to ids. That functionality is for now still
required by moc and can't be removed yet.
Change-Id: Ib4f8e9c71e1e7d99d52da9e44477c9a1f1805e57
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/dbus')
-rw-r--r-- | src/dbus/qdbusabstractinterface.cpp | 4 | ||||
-rw-r--r-- | src/dbus/qdbusargument.cpp | 6 | ||||
-rw-r--r-- | src/dbus/qdbusintegrator.cpp | 4 | ||||
-rw-r--r-- | src/dbus/qdbusmarshaller.cpp | 22 | ||||
-rw-r--r-- | src/dbus/qdbusmetaobject.cpp | 22 | ||||
-rw-r--r-- | src/dbus/qdbusmisc.cpp | 4 | ||||
-rw-r--r-- | src/dbus/qdbuspendingcall.cpp | 2 | ||||
-rw-r--r-- | src/dbus/qdbusreply.cpp | 2 | ||||
-rw-r--r-- | src/dbus/qdbusxmlgenerator.cpp | 8 |
9 files changed, 39 insertions, 35 deletions
diff --git a/src/dbus/qdbusabstractinterface.cpp b/src/dbus/qdbusabstractinterface.cpp index 60df1b30aa..2c348c857d 100644 --- a/src/dbus/qdbusabstractinterface.cpp +++ b/src/dbus/qdbusabstractinterface.cpp @@ -199,8 +199,8 @@ bool QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, void *retu if (type == QMetaType::QVariant) { *reinterpret_cast<QVariant*>(returnValuePtr) = value; } else { - QMetaType::destruct(type, returnValuePtr); - QMetaType::construct(type, returnValuePtr, value.constData()); + QMetaType(type).destruct(returnValuePtr); + QMetaType(type).construct(returnValuePtr, value.constData()); } return true; } diff --git a/src/dbus/qdbusargument.cpp b/src/dbus/qdbusargument.cpp index ef630a766c..854e5f9e29 100644 --- a/src/dbus/qdbusargument.cpp +++ b/src/dbus/qdbusargument.cpp @@ -86,7 +86,7 @@ QByteArray QDBusArgumentPrivate::createSignature(int id) if (signature.isEmpty() || !ok || !QDBusUtil::isValidSingleSignature(QString::fromLatin1(signature))) { qWarning("QDBusMarshaller: type `%s' produces invalid D-BUS signature `%s' " "(Did you forget to call beginStructure() ?)", - QMetaType::typeName(id), + QMetaType(id).name(), signature.isEmpty() ? "<empty>" : signature.constData()); return ""; } else if ((signature.at(0) != DBUS_TYPE_ARRAY && signature.at(0) != DBUS_STRUCT_BEGIN_CHAR) || @@ -94,9 +94,9 @@ QByteArray QDBusArgumentPrivate::createSignature(int id) signature.at(1) == DBUS_TYPE_STRING))) { qWarning("QDBusMarshaller: type `%s' attempts to redefine basic D-BUS type '%s' (%s) " "(Did you forget to call beginStructure() ?)", - QMetaType::typeName(id), + QMetaType(id).name(), signature.constData(), - QMetaType::typeName(QDBusMetaType::signatureToType(signature))); + QMetaType(QDBusMetaType::signatureToType(signature)).name()); return ""; } return signature; diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 74bebc7459..24a571e227 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -960,8 +960,8 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q } else { qFatal("Internal error: got invalid meta type %d (%s) " "when trying to convert to meta type %d (%s)", - arg.userType(), QMetaType::typeName(arg.userType()), - id, QMetaType::typeName(id)); + arg.userType(), arg.metaType().name(), + id, QMetaType(id).name()); } } diff --git a/src/dbus/qdbusmarshaller.cpp b/src/dbus/qdbusmarshaller.cpp index c80131f41d..4288cd75db 100644 --- a/src/dbus/qdbusmarshaller.cpp +++ b/src/dbus/qdbusmarshaller.cpp @@ -210,9 +210,9 @@ inline bool QDBusMarshaller::append(const QDBusVariant &arg) if (!signature) { qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. " "Use qDBusRegisterMetaType to register it", - QMetaType::typeName(id), id); + QMetaType(id).name(), id); error(QLatin1String("Unregistered type %1 passed in arguments") - .arg(QLatin1String(QMetaType::typeName(id)))); + .arg(QLatin1String(QMetaType(id).name()))); return false; } @@ -252,9 +252,9 @@ inline QDBusMarshaller *QDBusMarshaller::beginArray(int id) if (!signature) { qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. " "Use qDBusRegisterMetaType to register it", - QMetaType::typeName(id), id); + QMetaType(id).name(), id); error(QLatin1String("Unregistered type %1 passed in arguments") - .arg(QLatin1String(QMetaType::typeName(id)))); + .arg(QLatin1String(QMetaType(id).name()))); return this; } @@ -267,22 +267,22 @@ inline QDBusMarshaller *QDBusMarshaller::beginMap(int kid, int vid) if (!ksignature) { qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. " "Use qDBusRegisterMetaType to register it", - QMetaType::typeName(kid), kid); + QMetaType(kid).name(), kid); error(QLatin1String("Unregistered type %1 passed in arguments") - .arg(QLatin1String(QMetaType::typeName(kid)))); + .arg(QLatin1String(QMetaType(kid).name()))); return this; } if (ksignature[1] != 0 || !QDBusUtil::isValidBasicType(*ksignature)) { qWarning("QDBusMarshaller: type '%s' (%d) cannot be used as the key type in a D-BUS map.", - QMetaType::typeName(kid), kid); + QMetaType(kid).name(), kid); error(QLatin1String("Type %1 passed in arguments cannot be used as a key in a map") - .arg(QLatin1String(QMetaType::typeName(kid)))); + .arg(QLatin1String(QMetaType(kid).name()))); return this; } const char *vsignature = QDBusMetaType::typeToSignature( QVariant::Type(vid) ); if (!vsignature) { - const char *typeName = QMetaType::typeName(vid); + const char *typeName = QMetaType(vid).name(); qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. " "Use qDBusRegisterMetaType to register it", typeName, vid); @@ -416,9 +416,9 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg) if (!signature) { qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. " "Use qDBusRegisterMetaType to register it", - QMetaType::typeName(id), id); + QMetaType(id).name(), id); error(QLatin1String("Unregistered type %1 passed in arguments") - .arg(QLatin1String(QMetaType::typeName(id)))); + .arg(QLatin1String(QMetaType(id).name()))); return false; } diff --git a/src/dbus/qdbusmetaobject.cpp b/src/dbus/qdbusmetaobject.cpp index 5162d07e0d..dee885395a 100644 --- a/src/dbus/qdbusmetaobject.cpp +++ b/src/dbus/qdbusmetaobject.cpp @@ -134,11 +134,8 @@ static int registerComplexDBusType(const QByteArray &typeName) const QByteArray name; QDBusRawTypeHandler(const QByteArray &name) : QtPrivate::QMetaTypeInterface { - 0, sizeof(void *), sizeof(void *), QMetaType::MovableType, nullptr, - name.constData(), 0, QtPrivate::RefCount{0}, - [](QtPrivate::QMetaTypeInterface *self) { - delete static_cast<QDBusRawTypeHandler *>(self); - }, + 0, sizeof(void *), sizeof(void *), QMetaType::MovableType, 0, nullptr, + name.constData(), nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr @@ -148,7 +145,14 @@ static int registerComplexDBusType(const QByteArray &typeName) }; static QBasicMutex mutex; - static QHash<QByteArray, QMetaType> hash; + static struct Hash : QHash<QByteArray, QMetaType> + { + ~Hash() + { + for (QMetaType entry : *this) + QMetaType::unregisterMetaType(std::move(entry)); + } + } hash; QMutexLocker lock(&mutex); QMetaType &metatype = hash[typeName]; if (!metatype.isValid()) @@ -192,7 +196,7 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature, if (!typeName.isEmpty()) { // type name found - type = QMetaType::type(typeName); + type = QMetaType::fromName(typeName).id(); } if (type == QMetaType::UnknownType || signature != QDBusMetaType::typeToSignature(type)) { @@ -221,7 +225,7 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature, type = registerComplexDBusType(result.name); } } else { - result.name = QMetaType::typeName(type); + result.name = QMetaType(type).name(); } result.id = type; @@ -501,7 +505,7 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj) Q_ASSERT(mm.outputTypes.size() > 1); type = mm.outputTypes.at(i - mm.inputTypes.size() + 1); // Output parameters are references; type id not available - typeName = QMetaType::typeName(type); + typeName = QMetaType(type).name(); typeName.append('&'); } Q_ASSERT(type != QMetaType::UnknownType); diff --git a/src/dbus/qdbusmisc.cpp b/src/dbus/qdbusmisc.cpp index ba98184ded..c653e71097 100644 --- a/src/dbus/qdbusmisc.cpp +++ b/src/dbus/qdbusmisc.cpp @@ -164,7 +164,7 @@ int qDBusParametersForMethod(const QList<QByteArray> ¶meterTypes, QList<int> QByteArray basictype = type; basictype.truncate(type.length() - 1); - int id = QMetaType::type(basictype); + int id = QMetaType::fromName(basictype).id(); if (id == 0) { errorMsg = QLatin1String("Unregistered output type in parameter list: ") + QLatin1String(type); return -1; @@ -184,7 +184,7 @@ int qDBusParametersForMethod(const QList<QByteArray> ¶meterTypes, QList<int> if (type.startsWith("QVector<")) type = "QList<" + type.mid(sizeof("QVector<") - 1); - int id = QMetaType::type(type); + int id = QMetaType::fromName(type).id(); #ifdef QT_BOOTSTRAPPED // in bootstrap mode QDBusMessage isn't included, thus we need to resolve it manually here if (type == "QDBusMessage") { diff --git a/src/dbus/qdbuspendingcall.cpp b/src/dbus/qdbuspendingcall.cpp index 04d8e3f6c7..9bfdc8edce 100644 --- a/src/dbus/qdbuspendingcall.cpp +++ b/src/dbus/qdbuspendingcall.cpp @@ -198,7 +198,7 @@ void QDBusPendingCallPrivate::setMetaTypes(int count, const int *types) const char *typeSig = QDBusMetaType::typeToSignature(types[i]); if (Q_UNLIKELY(!typeSig)) { qFatal("QDBusPendingReply: type %s is not registered with QtDBus", - QMetaType::typeName(types[i])); + QMetaType(types[i]).name()); } sig += typeSig; } diff --git a/src/dbus/qdbusreply.cpp b/src/dbus/qdbusreply.cpp index 33bfadd701..3c6f1adf1a 100644 --- a/src/dbus/qdbusreply.cpp +++ b/src/dbus/qdbusreply.cpp @@ -225,7 +225,7 @@ void qDBusReplyFill(const QDBusMessage &reply, QDBusError &error, QVariant &data } else { // not an argument and doesn't match? int type = reply.arguments().at(0).userType(); - receivedType = QMetaType::typeName(type); + receivedType = QMetaType(type).name(); receivedSignature = QDBusMetaType::typeToSignature(type); } } diff --git a/src/dbus/qdbusxmlgenerator.cpp b/src/dbus/qdbusxmlgenerator.cpp index 97ce3dc910..7afeb66e09 100644 --- a/src/dbus/qdbusxmlgenerator.cpp +++ b/src/dbus/qdbusxmlgenerator.cpp @@ -114,7 +114,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method accessAsString(mp.isReadable(), mp.isWritable())); if (QDBusMetaType::signatureToType(signature) == QMetaType::UnknownType) { - const char *typeName = QMetaType::typeName(typeId); + const char *typeName = QMetaType(typeId).name(); retval += QLatin1String(">\n <annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"%3\"/>\n </property>\n") .arg(typeNameToXml(typeName)); } else { @@ -163,9 +163,9 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method // do we need to describe this argument? if (QDBusMetaType::signatureToType(typeName) == QMetaType::UnknownType) xml += QLatin1String(" <annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"%1\"/>\n") - .arg(typeNameToXml(QMetaType::typeName(typeId))); + .arg(typeNameToXml(QMetaType(typeId).name())); } else { - qWarning() << "Unsupported return type" << typeId << QMetaType::typeName(typeId) << "in method" << mm.name(); + qWarning() << "Unsupported return type" << typeId << QMetaType(typeId).name() << "in method" << mm.name(); continue; } } @@ -209,7 +209,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method // do we need to describe this argument? if (QDBusMetaType::signatureToType(signature) == QMetaType::UnknownType) { - const char *typeName = QMetaType::typeName(types.at(j)); + const char *typeName = QMetaType(types.at(j)).name(); xml += QString::fromLatin1(" <annotation name=\"org.qtproject.QtDBus.QtTypeName.%1%2\" value=\"%3\"/>\n") .arg(isOutput ? QLatin1String("Out") : QLatin1String("In")) .arg(isOutput && !isSignal ? j - inputCount : j - 1) |