Use QMetaType instead of integer based type ids

Change the implementation of Qt DBus to use QMetaType directly
instead of integer based type ids.

Change-Id: I999023b58fa50dcc3504386467faf09874f7d2cf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Lars Knoll 2020-09-09 13:42:35 +02:00
parent be714154fa
commit 850d850c5a
30 changed files with 173 additions and 183 deletions

View File

@ -305,7 +305,7 @@ void QDBusAdaptorConnector::relay(QObject *senderObj, int lastSignalIdx, void **
realObject = realObject->parent();
// break down the parameter list
QList<int> types;
QList<QMetaType> types;
QString errorMsg;
int inputCount = qDBusParametersForMethod(mm, types, errorMsg);
if (inputCount == -1) {

View File

@ -154,10 +154,10 @@ bool QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, void *retu
if (!isValid || !canMakeCalls()) // can't make calls
return false;
const int type = mp.userType();
QMetaType type = mp.metaType();
// is this metatype registered?
const char *expectedSignature = "";
if (int(mp.userType()) != QMetaType::QVariant) {
if (type.id() != QMetaType::QVariant) {
expectedSignature = QDBusMetaType::typeToSignature(type);
if (expectedSignature == nullptr) {
qWarning("QDBusAbstractInterface: type %s must be registered with Qt D-Bus before it can be "
@ -193,10 +193,10 @@ bool QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, void *retu
const char *foundType = nullptr;
QVariant value = qvariant_cast<QDBusVariant>(reply.arguments().at(0)).variant();
if (value.userType() == type || type == QMetaType::QVariant
if (value.metaType() == type || type.id() == QMetaType::QVariant
|| (expectedSignature[0] == 'v' && expectedSignature[1] == '\0')) {
// simple match
if (type == QMetaType::QVariant) {
if (type.id() == QMetaType::QVariant) {
*reinterpret_cast<QVariant*>(returnValuePtr) = value;
} else {
QMetaType(type).destruct(returnValuePtr);
@ -205,7 +205,7 @@ bool QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, void *retu
return true;
}
if (value.userType() == qMetaTypeId<QDBusArgument>()) {
if (value.metaType() == QMetaType::fromType<QDBusArgument>()) {
QDBusArgument arg = qvariant_cast<QDBusArgument>(value);
foundType = "user type";
@ -216,7 +216,7 @@ bool QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, void *retu
}
} else {
foundType = value.typeName();
foundSignature = QDBusMetaType::typeToSignature(value.userType());
foundSignature = QDBusMetaType::typeToSignature(value.metaType());
}
// there was an error...
@ -281,7 +281,7 @@ int QDBusAbstractInterfaceBase::qt_metacall(QMetaObject::Call _c, int _id, void
if (_c == QMetaObject::WriteProperty) {
QVariant value;
if (mp.userType() == qMetaTypeId<QDBusVariant>())
if (mp.metaType() == QMetaType::fromType<QDBusVariant>())
value = reinterpret_cast<const QDBusVariant*>(_a[0])->variant();
else
value = QVariant(mp.metaType(), _a[0]);

View File

@ -96,7 +96,7 @@ QByteArray QDBusArgumentPrivate::createSignature(int id)
"(Did you forget to call beginStructure() ?)",
QMetaType(id).name(),
signature.constData(),
QMetaType(QDBusMetaType::signatureToType(signature)).name());
QDBusMetaType::signatureToMetaType(signature).name());
return "";
}
return signature;
@ -879,7 +879,7 @@ void QDBusArgument::endStructure()
\sa endArray(), beginStructure(), beginMap()
*/
void QDBusArgument::beginArray(int id)
void QDBusArgument::beginArray(QMetaType id)
{
if (QDBusArgumentPrivate::checkWrite(d))
d = d->marshaller()->beginArray(id);
@ -916,10 +916,10 @@ void QDBusArgument::endArray()
\sa endMap(), beginStructure(), beginArray(), beginMapEntry()
*/
void QDBusArgument::beginMap(int kid, int vid)
void QDBusArgument::beginMap(QMetaType keyMetaType, QMetaType valueMetaType)
{
if (QDBusArgumentPrivate::checkWrite(d))
d = d->marshaller()->beginMap(kid, vid);
d = d->marshaller()->beginMap(keyMetaType, valueMetaType);
}
/*!

View File

@ -103,9 +103,13 @@ public:
void beginStructure();
void endStructure();
void beginArray(int elementMetaTypeId);
void beginArray(int elementMetaTypeId)
{ beginArray(QMetaType(elementMetaTypeId)); }
void beginArray(QMetaType elementMetaType);
void endArray();
void beginMap(int keyMetaTypeId, int valueMetaTypeId);
void beginMap(int keyMetaTypeId, int valueMetaTypeId)
{ beginMap(QMetaType(keyMetaTypeId), QMetaType(valueMetaTypeId)); }
void beginMap(QMetaType keyMetaType, QMetaType valueMetaType);
void endMap();
void beginMapEntry();
void endMapEntry();
@ -165,8 +169,7 @@ template<typename T> inline T qdbus_cast(const QDBusArgument &arg)
template<typename T> inline T qdbus_cast(const QVariant &v)
{
int id = v.userType();
if (id == qMetaTypeId<QDBusArgument>())
if (v.metaType() == QMetaType::fromType<QDBusArgument>())
return qdbus_cast<T>(qvariant_cast<QDBusArgument>(v));
else
return qvariant_cast<T>(v);
@ -227,8 +230,7 @@ template<template <typename> class Container, typename T,
typename = typename Container<T>::iterator>
inline QDBusArgument &operator<<(QDBusArgument &arg, const Container<T> &list)
{
int id = qMetaTypeId<T>();
arg.beginArray(id);
arg.beginArray(QMetaType::fromType<T>());
typename Container<T>::const_iterator it = list.begin();
typename Container<T>::const_iterator end = list.end();
for ( ; it != end; ++it)
@ -255,8 +257,7 @@ inline const QDBusArgument &operator>>(const QDBusArgument &arg, Container<T> &l
inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantList &list)
{
int id = qMetaTypeId<QDBusVariant>();
arg.beginArray(id);
arg.beginArray(QMetaType::fromType<QDBusVariant>());
QVariantList::ConstIterator it = list.constBegin();
QVariantList::ConstIterator end = list.constEnd();
for ( ; it != end; ++it)
@ -270,9 +271,7 @@ template <template <typename, typename> class Container, typename Key, typename
QtPrivate::IfAssociativeIteratorHasKeyAndValue<typename Container<Key, T>::iterator> = true>
inline QDBusArgument &operator<<(QDBusArgument &arg, const Container<Key, T> &map)
{
int kid = qMetaTypeId<Key>();
int vid = qMetaTypeId<T>();
arg.beginMap(kid, vid);
arg.beginMap(QMetaType::fromType<Key>(), QMetaType::fromType<T>());
auto it = map.begin();
auto end = map.end();
for ( ; it != end; ++it) {
@ -288,9 +287,7 @@ template <template <typename, typename> class Container, typename Key, typename
QtPrivate::IfAssociativeIteratorHasFirstAndSecond<typename Container<Key, T>::iterator> = true>
inline QDBusArgument &operator<<(QDBusArgument &arg, const Container<Key, T> &map)
{
int kid = qMetaTypeId<Key>();
int vid = qMetaTypeId<T>();
arg.beginMap(kid, vid);
arg.beginMap(QMetaType::fromType<Key>(), QMetaType::fromType<T>());
auto it = map.begin();
auto end = map.end();
for ( ; it != end; ++it) {
@ -322,7 +319,7 @@ inline const QDBusArgument &operator>>(const QDBusArgument &arg, Container<Key,
inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantMap &map)
{
arg.beginMap(QMetaType::QString, qMetaTypeId<QDBusVariant>());
arg.beginMap(QMetaType::fromType<QString>(), QMetaType::fromType<QDBusVariant>());
QVariantMap::ConstIterator it = map.constBegin();
QVariantMap::ConstIterator end = map.constEnd();
for ( ; it != end; ++it) {
@ -336,7 +333,7 @@ inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantMap &map)
inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantHash &map)
{
arg.beginMap(QMetaType::QString, qMetaTypeId<QDBusVariant>());
arg.beginMap(QMetaType::fromType<QString>(), QMetaType::fromType<QDBusVariant>());
QVariantHash::ConstIterator it = map.constBegin();
QVariantHash::ConstIterator end = map.constEnd();
for ( ; it != end; ++it) {

View File

@ -129,9 +129,9 @@ public:
QDBusMarshaller *beginStructure();
QDBusMarshaller *endStructure();
QDBusMarshaller *beginArray(int id);
QDBusMarshaller *beginArray(QMetaType id);
QDBusMarshaller *endArray();
QDBusMarshaller *beginMap(int kid, int vid);
QDBusMarshaller *beginMap(QMetaType kid, QMetaType vid);
QDBusMarshaller *endMap();
QDBusMarshaller *beginMapEntry();
QDBusMarshaller *endMapEntry();

View File

@ -137,7 +137,7 @@ public:
QString service, path, signature;
QObject* obj;
int midx;
QList<int> params;
QList<QMetaType> params;
ArgMatchRules argumentMatch;
QByteArray matchRule;
};
@ -264,7 +264,7 @@ private:
void sendInternal(QDBusPendingCallPrivate *pcall, void *msg, int timeout);
void sendError(const QDBusMessage &msg, QDBusError::ErrorType code);
void deliverCall(QObject *object, int flags, const QDBusMessage &msg,
const QList<int> &metaTypes, int slotIdx);
const QList<QMetaType> &metaTypes, int slotIdx);
SignalHookHash::Iterator removeSignalHookNoLock(SignalHookHash::Iterator it);
void collectAllObjects(ObjectTreeNode &node, QSet<QObject *> &set);
@ -352,7 +352,7 @@ public:
public:
// static methods
static int findSlot(QObject *obj, const QByteArray &normalizedName, QList<int> &params);
static int findSlot(QObject *obj, const QByteArray &normalizedName, QList<QMetaType> &params);
static bool prepareHook(QDBusConnectionPrivate::SignalHook &hook, QString &key,
const QString &service,
const QString &path, const QString &interface, const QString &name,
@ -361,7 +361,7 @@ public:
bool buildSignature);
static DBusHandlerResult messageFilter(DBusConnection *, DBusMessage *, void *);
static QDBusCallDeliveryEvent *prepareReply(QDBusConnectionPrivate *target, QObject *object,
int idx, const QList<int> &metaTypes,
int idx, const QList<QMetaType> &metaTypes,
const QDBusMessage &msg);
static void processFinishedCall(QDBusPendingCallPrivate *call);
@ -374,11 +374,10 @@ public:
};
// in qdbusmisc.cpp
extern int qDBusParametersForMethod(const QMetaMethod &mm, QList<int> &metaTypes,
QString &errorMsg);
extern int qDBusParametersForMethod(const QMetaMethod &mm, QList<QMetaType> &metaTypes, QString &errorMsg);
# endif // QT_BOOTSTRAPPED
extern Q_DBUS_EXPORT int qDBusParametersForMethod(const QList<QByteArray> &parameters,
QList<int> &metaTypes, QString &errorMsg);
QList<QMetaType> &metaTypes, QString &errorMsg);
extern Q_DBUS_EXPORT bool qDBusCheckAsyncTag(const char *tag);
#ifndef QT_BOOTSTRAPPED
extern bool qDBusInterfaceInObject(QObject *obj, const QString &interface_name);

View File

@ -668,7 +668,7 @@ static void huntAndEmit(DBusConnection *connection, DBusMessage *msg,
}
static int findSlot(const QMetaObject *mo, const QByteArray &name, int flags,
const QString &signature_, QList<int> &metaTypes)
const QString &signature_, QList<QMetaType> &metaTypes)
{
QByteArray msgSignature = signature_.toLatin1();
@ -687,12 +687,12 @@ static int findSlot(const QMetaObject *mo, const QByteArray &name, int flags,
if (mm.name() != name)
continue;
int returnType = mm.returnType();
QMetaType returnType = mm.returnMetaType();
bool isAsync = qDBusCheckAsyncTag(mm.tag());
bool isScriptable = mm.attributes() & QMetaMethod::Scriptable;
// consistency check:
if (isAsync && returnType != QMetaType::Void)
if (isAsync && returnType.id() != QMetaType::Void)
continue;
QString errorMsg;
@ -729,7 +729,7 @@ static int findSlot(const QMetaObject *mo, const QByteArray &name, int flags,
++i;
// make sure that the output parameters have signatures too
if (returnType != QMetaType::UnknownType && returnType != QMetaType::Void && QDBusMetaType::typeToSignature(returnType) == nullptr)
if (returnType.isValid() && returnType.id() != QMetaType::Void && QDBusMetaType::typeToSignature(returnType) == nullptr)
continue;
bool ok = true;
@ -781,7 +781,7 @@ static QDBusCallDeliveryEvent * const DIRECT_DELIVERY = (QDBusCallDeliveryEvent
QDBusCallDeliveryEvent *QDBusConnectionPrivate::prepareReply(QDBusConnectionPrivate *target,
QObject *object, int idx,
const QList<int> &metaTypes,
const QList<QMetaType> &metaTypes,
const QDBusMessage &msg)
{
Q_ASSERT(object);
@ -796,8 +796,8 @@ QDBusCallDeliveryEvent *QDBusConnectionPrivate::prepareReply(QDBusConnectionPriv
// check that types match
for (int i = 0; i < n; ++i)
if (metaTypes.at(i + 1) != msg.arguments().at(i).userType() &&
msg.arguments().at(i).userType() != qMetaTypeId<QDBusArgument>())
if (metaTypes.at(i + 1) != msg.arguments().at(i).metaType() &&
msg.arguments().at(i).metaType() != QMetaType::fromType<QDBusArgument>())
return nullptr; // no match
// we can deliver
@ -917,7 +917,7 @@ bool QDBusConnectionPrivate::activateCall(QObject* object, int flags, const QDBu
}
void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const QDBusMessage &msg,
const QList<int> &metaTypes, int slotIdx)
const QList<QMetaType> &metaTypes, int slotIdx)
{
Q_ASSERT_X(!object || QThread::currentThread() == object->thread(),
"QDBusConnection: internal threading error",
@ -936,15 +936,15 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q
int i;
int pCount = qMin(msg.arguments().count(), metaTypes.count() - 1);
for (i = 1; i <= pCount; ++i) {
int id = metaTypes[i];
auto id = metaTypes[i];
if (id == QDBusMetaTypeId::message())
break;
const QVariant &arg = msg.arguments().at(i - 1);
if (arg.userType() == id)
if (arg.metaType() == id)
// no conversion needed
params.append(const_cast<void *>(arg.constData()));
else if (arg.userType() == qMetaTypeId<QDBusArgument>()) {
else if (arg.metaType() == QMetaType::fromType<QDBusArgument>()) {
// convert to what the function expects
auxParameters.append(QVariant(QMetaType(id)));
@ -954,14 +954,14 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q
if (Q_UNLIKELY(!QDBusMetaType::demarshall(in, out.metaType(), out.data())))
qFatal("Internal error: demarshalling function for type '%s' (%d) failed!",
out.typeName(), out.userType());
out.typeName(), out.metaType().id());
params.append(const_cast<void *>(out.constData()));
} else {
qFatal("Internal error: got invalid meta type %d (%s) "
"when trying to convert to meta type %d (%s)",
arg.userType(), arg.metaType().name(),
id, QMetaType(id).name());
arg.metaType().id(), arg.metaType().name(),
id.id(), id.name());
}
}
@ -973,7 +973,7 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q
// output arguments
const int numMetaTypes = metaTypes.count();
QVariantList outputArgs;
if (metaTypes[0] != QMetaType::Void && metaTypes[0] != QMetaType::UnknownType) {
if (metaTypes[0].id() != QMetaType::Void && metaTypes[0].isValid()) {
outputArgs.reserve(numMetaTypes - i + 1);
QVariant arg{QMetaType(metaTypes[0])};
outputArgs.append( arg );
@ -1315,7 +1315,7 @@ void QDBusConnectionPrivate::serviceOwnerChangedNoLock(const QString &name,
}
int QDBusConnectionPrivate::findSlot(QObject *obj, const QByteArray &normalizedName,
QList<int> &params)
QList<QMetaType> &params)
{
int midx = obj->metaObject()->indexOfMethod(normalizedName);
if (midx == -1)
@ -1703,7 +1703,7 @@ void QDBusConnectionPrivate::watchForDBusDisconnection()
hook.service.clear(); // org.freedesktop.DBus.Local.Disconnected uses empty service name
hook.path = QDBusUtil::dbusPathLocal();
hook.obj = this;
hook.params << QMetaType::Void;
hook.params << QMetaType(QMetaType::Void);
hook.midx = staticMetaObject.indexOfSlot("handleDBusDisconnection()");
Q_ASSERT(hook.midx != -1);
signalHooks.insert(QLatin1String("Disconnected:" DBUS_INTERFACE_LOCAL), hook);
@ -1840,7 +1840,7 @@ void QDBusConnectionPrivate::setConnection(DBusConnection *dbc, const QDBusError
hook.service = QDBusUtil::dbusService();
hook.path.clear(); // no matching
hook.obj = this;
hook.params << QMetaType::Void << QMetaType::QString; // both functions take a QString as parameter and return void
hook.params << QMetaType(QMetaType::Void) << QMetaType(QMetaType::QString); // both functions take a QString as parameter and return void
hook.midx = staticMetaObject.indexOfSlot("registerServiceNoLock(QString)");
Q_ASSERT(hook.midx != -1);
@ -1854,7 +1854,7 @@ void QDBusConnectionPrivate::setConnection(DBusConnection *dbc, const QDBusError
// we don't use connectSignal here because the rules are added by connectSignal on a per-need basis
hook.params.clear();
hook.params.reserve(4);
hook.params << QMetaType::Void << QMetaType::QString << QMetaType::QString << QMetaType::QString;
hook.params << QMetaType(QMetaType::Void) << QMetaType(QMetaType::QString) << QMetaType(QMetaType::QString) << QMetaType(QMetaType::QString);
hook.midx = staticMetaObject.indexOfSlot("serviceOwnerChangedNoLock(QString,QString,QString)");
Q_ASSERT(hook.midx != -1);
signalHooks.insert(QLatin1String("NameOwnerChanged:" DBUS_INTERFACE_DBUS), hook);

View File

@ -84,7 +84,7 @@ struct QDBusSlotCache
{
int flags;
int slotIdx;
QList<int> metaTypes;
QList<QMetaType> metaTypes;
void swap(Data &other) noexcept
{
@ -105,7 +105,7 @@ class QDBusCallDeliveryEvent: public QAbstractMetaCallEvent
{
public:
QDBusCallDeliveryEvent(const QDBusConnection &c, int id, QObject *sender,
const QDBusMessage &msg, const QList<int> &types, int f = 0)
const QDBusMessage &msg, const QList<QMetaType> &types, int f = 0)
: QAbstractMetaCallEvent(sender, -1),
connection(c),
message(msg),
@ -123,7 +123,7 @@ public:
private:
QDBusConnection connection; // just for refcounting
QDBusMessage message;
QList<int> metaTypes;
QList<QMetaType> metaTypes;
int id;
int flags;
};

View File

@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
static void copyArgument(void *to, int id, const QVariant &arg)
{
if (id == arg.userType()) {
if (id == arg.metaType().id()) {
switch (id) {
case QMetaType::Bool:
*reinterpret_cast<bool *>(to) = arg.toBool();
@ -104,13 +104,13 @@ static void copyArgument(void *to, int id, const QVariant &arg)
return;
}
if (id == QDBusMetaTypeId::variant()) {
if (id == QDBusMetaTypeId::variant().id()) {
*reinterpret_cast<QDBusVariant *>(to) = qvariant_cast<QDBusVariant>(arg);
return;
} else if (id == QDBusMetaTypeId::objectpath()) {
} else if (id == QDBusMetaTypeId::objectpath().id()) {
*reinterpret_cast<QDBusObjectPath *>(to) = qvariant_cast<QDBusObjectPath>(arg);
return;
} else if (id == QDBusMetaTypeId::signature()) {
} else if (id == QDBusMetaTypeId::signature().id()) {
*reinterpret_cast<QDBusSignature *>(to) = qvariant_cast<QDBusSignature>(arg);
return;
}
@ -121,14 +121,14 @@ static void copyArgument(void *to, int id, const QVariant &arg)
}
// if we got here, it's either an un-dermarshalled type or a mismatch
if (arg.userType() != QDBusMetaTypeId::argument()) {
if (arg.metaType() != QDBusMetaTypeId::argument()) {
// it's a mismatch
//qWarning?
return;
}
// is this type registered?
const char *userSignature = QDBusMetaType::typeToSignature(id);
const char *userSignature = QDBusMetaType::typeToSignature(QMetaType(id));
if (!userSignature || !*userSignature) {
// type not registered
//qWarning?

View File

@ -348,28 +348,28 @@ static int writeProperty(QObject *obj, const QByteArray &property_name, QVariant
// we found our property
// do we have the right type?
int id = mp.userType();
if (!id){
QMetaType id = mp.metaType();
if (!id.isValid()){
// type not registered or invalid / void?
qWarning("QDBusConnection: Unable to handle unregistered datatype '%s' for property '%s::%s'",
mp.typeName(), mo->className(), property_name.constData());
return PropertyWriteFailed;
}
if (id != QMetaType::QVariant && value.userType() == QDBusMetaTypeId::argument()) {
if (id.id() != QMetaType::QVariant && value.metaType() == QDBusMetaTypeId::argument()) {
// we have to demarshall before writing
QVariant other{QMetaType(id)};
if (!QDBusMetaType::demarshall(qvariant_cast<QDBusArgument>(value), other.metaType(), other.data())) {
qWarning("QDBusConnection: type `%s' (%d) is not registered with QtDBus. "
"Use qDBusRegisterMetaType to register it",
mp.typeName(), id);
mp.typeName(), id.id());
return PropertyWriteFailed;
}
value = other;
}
if (mp.userType() == qMetaTypeId<QDBusVariant>())
if (mp.metaType() == QMetaType::fromType<QDBusVariant>())
value = QVariant::fromValue(QDBusVariant(value));
// the property type here should match
@ -456,10 +456,10 @@ static QVariantMap readAllProperties(QObject *object, int flags)
continue;
// is it a registered property?
int typeId = mp.userType();
if (!typeId)
QMetaType type = mp.metaType();
if (!type.isValid())
continue;
const char *signature = QDBusMetaType::typeToSignature(typeId);
const char *signature = QDBusMetaType::typeToSignature(type);
if (!signature)
continue;

View File

@ -189,8 +189,8 @@ inline bool QDBusMarshaller::append(const QDBusVariant &arg)
}
const QVariant &value = arg.variant();
int id = value.userType();
if (id == QMetaType::UnknownType) {
QMetaType id = value.metaType();
if (!id.isValid()) {
qWarning("QDBusMarshaller: cannot add a null QDBusVariant");
error(QLatin1String("Variant containing QVariant::Invalid passed in arguments"));
return false;
@ -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(id).name(), id);
id.name(), id.id());
error(QLatin1String("Unregistered type %1 passed in arguments")
.arg(QLatin1String(QMetaType(id).name())));
.arg(QLatin1String(id.name())));
return false;
}
@ -246,46 +246,46 @@ inline QDBusMarshaller *QDBusMarshaller::beginStructure()
return beginCommon(DBUS_TYPE_STRUCT, nullptr);
}
inline QDBusMarshaller *QDBusMarshaller::beginArray(int id)
inline QDBusMarshaller *QDBusMarshaller::beginArray(QMetaType id)
{
const char *signature = QDBusMetaType::typeToSignature( QVariant::Type(id) );
const char *signature = QDBusMetaType::typeToSignature(id);
if (!signature) {
qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. "
"Use qDBusRegisterMetaType to register it",
QMetaType(id).name(), id);
id.name(), id.id());
error(QLatin1String("Unregistered type %1 passed in arguments")
.arg(QLatin1String(QMetaType(id).name())));
.arg(QLatin1String(id.name())));
return this;
}
return beginCommon(DBUS_TYPE_ARRAY, signature);
}
inline QDBusMarshaller *QDBusMarshaller::beginMap(int kid, int vid)
inline QDBusMarshaller *QDBusMarshaller::beginMap(QMetaType kid, QMetaType vid)
{
const char *ksignature = QDBusMetaType::typeToSignature( QVariant::Type(kid) );
const char *ksignature = QDBusMetaType::typeToSignature(kid);
if (!ksignature) {
qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. "
"Use qDBusRegisterMetaType to register it",
QMetaType(kid).name(), kid);
kid.name(), kid.id());
error(QLatin1String("Unregistered type %1 passed in arguments")
.arg(QLatin1String(QMetaType(kid).name())));
.arg(QLatin1String(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(kid).name(), kid);
kid.name(), kid.id());
error(QLatin1String("Type %1 passed in arguments cannot be used as a key in a map")
.arg(QLatin1String(QMetaType(kid).name())));
.arg(QLatin1String(kid.name())));
return this;
}
const char *vsignature = QDBusMetaType::typeToSignature( QVariant::Type(vid) );
const char *vsignature = QDBusMetaType::typeToSignature(vid);
if (!vsignature) {
const char *typeName = QMetaType(vid).name();
const char *typeName = vid.name();
qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. "
"Use qDBusRegisterMetaType to register it",
typeName, vid);
typeName, vid.id());
error(QLatin1String("Unregistered type %1 passed in arguments")
.arg(QLatin1String(typeName)));
return this;
@ -383,8 +383,8 @@ void QDBusMarshaller::error(const QString &msg)
bool QDBusMarshaller::appendVariantInternal(const QVariant &arg)
{
int id = arg.userType();
if (id == QMetaType::UnknownType) {
QMetaType id = arg.metaType();
if (!id.isValid()) {
qWarning("QDBusMarshaller: cannot add an invalid QVariant");
error(QLatin1String("Variant containing QVariant::Invalid passed in arguments"));
return false;
@ -412,13 +412,13 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg)
return appendCrossMarshalling(&demarshaller);
}
const char *signature = QDBusMetaType::typeToSignature( QVariant::Type(id) );
const char *signature = QDBusMetaType::typeToSignature(id);
if (!signature) {
qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. "
"Use qDBusRegisterMetaType to register it",
QMetaType(id).name(), id);
id.name(), id.id());
error(QLatin1String("Unregistered type %1 passed in arguments")
.arg(QLatin1String(QMetaType(id).name())));
.arg(QLatin1String(id.name())));
return false;
}
@ -485,7 +485,7 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg)
case DBUS_TYPE_ARRAY:
// could be many things
// find out what kind of array it is
switch (arg.userType()) {
switch (arg.metaType().id()) {
case QMetaType::QStringList:
append( arg.toStringList() );
return true;

View File

@ -274,10 +274,10 @@ QDBusMessage QDBusMessagePrivate::makeLocal(const QDBusConnectionPrivate &conn,
QVariantList::ConstIterator it = asSent.d_ptr->arguments.constBegin();
QVariantList::ConstIterator end = asSent.d_ptr->arguments.constEnd();
for ( ; it != end; ++it) {
int id = it->userType();
QMetaType id = it->metaType();
const char *signature = QDBusMetaType::typeToSignature(id);
if ((id != QMetaType::QStringList && id != QMetaType::QByteArray &&
qstrlen(signature) != 1) || id == qMetaTypeId<QDBusVariant>()) {
if ((id.id() != QMetaType::QStringList && id.id() != QMetaType::QByteArray &&
qstrlen(signature) != 1) || id == QMetaType::fromType<QDBusVariant>()) {
// yes, we are
// we must marshall and demarshall again so as to create QDBusArgument
// entries for the complex types

View File

@ -45,7 +45,7 @@
#include <QtCore/qlist.h>
#include <QtCore/qvariant.h>
#ifndef QT_NO_DBUS
#if !defined(QT_NO_DBUS) && !defined(QT_BOOTSTRAPPED)
#if defined(Q_OS_WIN) && defined(interface)
# undef interface
@ -53,7 +53,6 @@
QT_BEGIN_NAMESPACE
class QDBusMessagePrivate;
class Q_DBUS_EXPORT QDBusMessage
{

View File

@ -170,7 +170,7 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
Type result;
result.id = QMetaType::UnknownType;
int type = QDBusMetaType::signatureToType(signature);
int type = QDBusMetaType::signatureToMetaType(signature).id();
if (type == QMetaType::UnknownType && !qt_dbus_metaobject_skip_annotations) {
// it's not a type normally handled by our meta type system
// it must contain an annotation
@ -199,7 +199,7 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
type = QMetaType::fromName(typeName).id();
}
if (type == QMetaType::UnknownType || signature != QDBusMetaType::typeToSignature(type)) {
if (type == QMetaType::UnknownType || signature != QDBusMetaType::typeToSignature(QMetaType(type))) {
// type is still unknown or doesn't match back to the signature that it
// was expected to, so synthesize a fake type
typeName = "QDBusRawType<0x" + signature.toHex() + ">*";

View File

@ -303,7 +303,7 @@ bool QDBusMetaType::demarshall(const QDBusArgument &arg, QMetaType metaType, voi
Note: this function only handles the basic D-Bus types.
\sa QDBusUtil::isValidSingleSignature(), typeToSignature(),
QVariant::type(), QVariant::userType()
QVariant::metaType()
*/
QMetaType QDBusMetaType::signatureToMetaType(const char *signature)
{
@ -388,7 +388,7 @@ QMetaType QDBusMetaType::signatureToMetaType(const char *signature)
More types can be registered with the qDBusRegisterMetaType() function.
\sa QDBusUtil::isValidSingleSignature(), signatureToType(),
QVariant::type(), QVariant::userType()
QVariant::metaType()
*/
const char *QDBusMetaType::typeToSignature(QMetaType type)
{

View File

@ -60,10 +60,6 @@ public:
static bool demarshall(const QDBusArgument &, QMetaType id, void *data);
static QMetaType signatureToMetaType(const char *signature);
static int signatureToType(const char *signature)
{ return signatureToMetaType(signature).id(); }
static const char *typeToSignature(int type)
{ return typeToSignature(QMetaType(type)); }
static const char *typeToSignature(QMetaType type);
};

View File

@ -66,37 +66,37 @@ QT_BEGIN_NAMESPACE
struct QDBusMetaTypeId
{
static int message(); // QDBusMessage
static int argument(); // QDBusArgument
static int variant(); // QDBusVariant
static int objectpath(); // QDBusObjectPath
static int signature(); // QDBusSignature
static int error(); // QDBusError
static int unixfd(); // QDBusUnixFileDescriptor
static QMetaType message(); // QDBusMessage
static QMetaType argument(); // QDBusArgument
static QMetaType variant(); // QDBusVariant
static QMetaType objectpath(); // QDBusObjectPath
static QMetaType signature(); // QDBusSignature
static QMetaType error(); // QDBusError
static QMetaType unixfd(); // QDBusUnixFileDescriptor
static void init();
};
inline int QDBusMetaTypeId::message()
{ return qMetaTypeId<QDBusMessage>(); }
inline QMetaType QDBusMetaTypeId::message()
{ return QMetaType::fromType<QDBusMessage>(); }
inline int QDBusMetaTypeId::argument()
{ return qMetaTypeId<QDBusArgument>(); }
inline QMetaType QDBusMetaTypeId::argument()
{ return QMetaType::fromType<QDBusArgument>(); }
inline int QDBusMetaTypeId::variant()
{ return qMetaTypeId<QDBusVariant>(); }
inline QMetaType QDBusMetaTypeId::variant()
{ return QMetaType::fromType<QDBusVariant>(); }
inline int QDBusMetaTypeId::objectpath()
{ return qMetaTypeId<QDBusObjectPath>(); }
inline QMetaType QDBusMetaTypeId::objectpath()
{ return QMetaType::fromType<QDBusObjectPath>(); }
inline int QDBusMetaTypeId::signature()
{ return qMetaTypeId<QDBusSignature>(); }
inline QMetaType QDBusMetaTypeId::signature()
{ return QMetaType::fromType<QDBusSignature>(); }
inline int QDBusMetaTypeId::error()
{ return qMetaTypeId<QDBusError>(); }
inline QMetaType QDBusMetaTypeId::error()
{ return QMetaType::fromType<QDBusError>(); }
inline int QDBusMetaTypeId::unixfd()
{ return qMetaTypeId<QDBusUnixFileDescriptor>(); }
inline QMetaType QDBusMetaTypeId::unixfd()
{ return QMetaType::fromType<QDBusUnixFileDescriptor>(); }
QT_END_NAMESPACE

View File

@ -135,20 +135,20 @@ bool qDBusInterfaceInObject(QObject *obj, const QString &interface_name)
// metaTypes.count() >= retval + 1 in all cases
//
// sig must be the normalised signature for the method
int qDBusParametersForMethod(const QMetaMethod &mm, QList<int> &metaTypes, QString &errorMsg)
int qDBusParametersForMethod(const QMetaMethod &mm, QList<QMetaType> &metaTypes, QString &errorMsg)
{
return qDBusParametersForMethod(mm.parameterTypes(), metaTypes, errorMsg);
}
#endif // QT_BOOTSTRAPPED
int qDBusParametersForMethod(const QList<QByteArray> &parameterTypes, QList<int> &metaTypes,
int qDBusParametersForMethod(const QList<QByteArray> &parameterTypes, QList<QMetaType> &metaTypes,
QString &errorMsg)
{
QDBusMetaTypeId::init();
metaTypes.clear();
metaTypes.append(0); // return type
metaTypes.append(QMetaType()); // return type
int inputCount = 0;
bool seenMessage = false;
QList<QByteArray>::ConstIterator it = parameterTypes.constBegin();
@ -164,14 +164,14 @@ int qDBusParametersForMethod(const QList<QByteArray> &parameterTypes, QList<int>
QByteArray basictype = type;
basictype.truncate(type.length() - 1);
int id = QMetaType::fromName(basictype).id();
if (id == 0) {
QMetaType id = QMetaType::fromName(basictype);
if (!id.isValid()) {
errorMsg = QLatin1String("Unregistered output type in parameter list: ") + QLatin1String(type);
return -1;
} else if (QDBusMetaType::typeToSignature(id) == nullptr)
return -1;
metaTypes.append( id );
metaTypes.append(id);
seenMessage = true; // it cannot appear anymore anyways
continue;
}
@ -184,7 +184,7 @@ int qDBusParametersForMethod(const QList<QByteArray> &parameterTypes, QList<int>
if (type.startsWith("QVector<"))
type = "QList<" + type.mid(sizeof("QVector<") - 1);
int id = QMetaType::fromName(type).id();
QMetaType id = QMetaType::fromName(type);
#ifdef QT_BOOTSTRAPPED
// in bootstrap mode QDBusMessage isn't included, thus we need to resolve it manually here
if (type == "QDBusMessage") {
@ -192,7 +192,7 @@ int qDBusParametersForMethod(const QList<QByteArray> &parameterTypes, QList<int>
}
#endif
if (id == QMetaType::UnknownType) {
if (!id.isValid()) {
errorMsg = QLatin1String("Unregistered input type in parameter list: ") + QLatin1String(type);
return -1;
}

View File

@ -185,7 +185,7 @@ bool QDBusPendingCallPrivate::setReplyCallback(QObject *target, const char *memb
return true;
}
void QDBusPendingCallPrivate::setMetaTypes(int count, const int *types)
void QDBusPendingCallPrivate::setMetaTypes(int count, const QMetaType *types)
{
if (count == 0) {
expectedReplySignature = QLatin1String(""); // not null
@ -196,10 +196,8 @@ void QDBusPendingCallPrivate::setMetaTypes(int count, const int *types)
sig.reserve(count + count / 2);
for (int i = 0; i < count; ++i) {
const char *typeSig = QDBusMetaType::typeToSignature(types[i]);
if (Q_UNLIKELY(!typeSig)) {
qFatal("QDBusPendingReply: type %s is not registered with QtDBus",
QMetaType(types[i]).name());
}
if (Q_UNLIKELY(!typeSig))
qFatal("QDBusPendingReply: type %s is not registered with QtDBus", types[i].name());
sig += typeSig;
}

View File

@ -82,7 +82,7 @@ public:
// for the callback mechanism (see setReplyCallback and QDBusConnectionPrivate::sendWithReplyAsync)
QPointer<QObject> receiver;
QList<int> metaTypes;
QList<QMetaType> metaTypes;
int methodIdx;
// }
@ -104,7 +104,7 @@ public:
~QDBusPendingCallPrivate();
bool setReplyCallback(QObject *target, const char *member);
void waitForFinished();
void setMetaTypes(int count, const int *types);
void setMetaTypes(int count, const QMetaType *types);
void checkReceivedSignature();
static QDBusPendingCall fromMessage(const QDBusMessage &msg);

View File

@ -275,7 +275,7 @@ QVariant QDBusPendingReplyBase::argumentAt(int index) const
return d->replyMessage.arguments().value(index);
}
void QDBusPendingReplyBase::setMetaTypes(int count, const int *types)
void QDBusPendingReplyBase::setMetaTypes(int count, const QMetaType *types)
{
Q_ASSERT(d);
const auto locker = qt_scoped_lock(d->mutex);

View File

@ -58,7 +58,7 @@ protected:
void assign(const QDBusMessage &message);
QVariant argumentAt(int index) const;
void setMetaTypes(int count, const int *metaTypes);
void setMetaTypes(int count, const QMetaType *metaTypes);
};
namespace QDBusPendingReplyTypes {
@ -144,7 +144,7 @@ private:
if constexpr (Count == 0) {
setMetaTypes(0, nullptr);
} else {
std::array<int, Count> typeIds = { QDBusPendingReplyTypes::metaTypeFor<Types>().id()... };
std::array<QMetaType, Count> typeIds = { QDBusPendingReplyTypes::metaTypeFor<Types>()... };
setMetaTypes(Count, typeIds.data());
}
}

View File

@ -203,17 +203,17 @@ void qDBusReplyFill(const QDBusMessage &reply, QDBusError &error, QVariant &data
return;
}
if (reply.arguments().count() >= 1 && reply.arguments().at(0).userType() == data.userType()) {
if (reply.arguments().count() >= 1 && reply.arguments().at(0).metaType() == data.metaType()) {
data = reply.arguments().at(0);
return;
}
const char *expectedSignature = QDBusMetaType::typeToSignature(data.userType());
const char *expectedSignature = QDBusMetaType::typeToSignature(data.metaType());
const char *receivedType = nullptr;
QByteArray receivedSignature;
if (reply.arguments().count() >= 1) {
if (reply.arguments().at(0).userType() == QDBusMetaTypeId::argument()) {
if (reply.arguments().at(0).metaType() == QDBusMetaTypeId::argument()) {
// compare signatures instead
QDBusArgument arg = qvariant_cast<QDBusArgument>(reply.arguments().at(0));
receivedSignature = arg.currentSignature().toLatin1();
@ -224,8 +224,8 @@ 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(type).name();
QMetaType type = reply.arguments().at(0).metaType();
receivedType = type.name();
receivedSignature = QDBusMetaType::typeToSignature(type);
}
}

View File

@ -80,7 +80,7 @@ static bool argToString(const QDBusArgument &arg, QString &out);
static bool variantToString(const QVariant &arg, QString &out)
{
int argType = arg.userType();
int argType = arg.metaType().id();
if (argType == QMetaType::QStringList) {
out += QLatin1Char('{');
@ -138,11 +138,11 @@ static bool variantToString(const QVariant &arg, QString &out)
} else if (argType == qMetaTypeId<QDBusVariant>()) {
const QVariant v = qvariant_cast<QDBusVariant>(arg).variant();
out += QLatin1String("[Variant");
int vUserType = v.userType();
if (vUserType != qMetaTypeId<QDBusVariant>()
&& vUserType != qMetaTypeId<QDBusSignature>()
&& vUserType != qMetaTypeId<QDBusObjectPath>()
&& vUserType != qMetaTypeId<QDBusArgument>())
QMetaType vUserType = v.metaType();
if (vUserType != QMetaType::fromType<QDBusVariant>()
&& vUserType != QMetaType::fromType<QDBusSignature>()
&& vUserType != QMetaType::fromType<QDBusObjectPath>()
&& vUserType != QMetaType::fromType<QDBusArgument>())
out += QLatin1Char('(') + QLatin1String(v.typeName()) + QLatin1Char(')');
out += QLatin1String(": ");
if (!variantToString(v, out))

View File

@ -101,10 +101,10 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
(!mp.isScriptable() && (flags & QDBusConnection::ExportNonScriptableProperties))))
continue;
int typeId = mp.userType();
if (!typeId)
QMetaType type = mp.metaType();
if (!type.isValid())
continue;
const char *signature = QDBusMetaType::typeToSignature(typeId);
const char *signature = QDBusMetaType::typeToSignature(type);
if (!signature)
continue;
@ -113,8 +113,8 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
QLatin1String(signature),
accessAsString(mp.isReadable(), mp.isWritable()));
if (QDBusMetaType::signatureToType(signature) == QMetaType::UnknownType) {
const char *typeName = QMetaType(typeId).name();
if (!QDBusMetaType::signatureToMetaType(signature).isValid()) {
const char *typeName = type.name();
retval += QLatin1String(">\n <annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"%3\"/>\n </property>\n")
.arg(typeNameToXml(typeName));
} else {
@ -153,29 +153,29 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
isSignal ? "signal" : "method", mm.name().constData());
// check the return type first
int typeId = mm.returnType();
if (typeId != QMetaType::UnknownType && typeId != QMetaType::Void) {
QMetaType typeId = mm.returnMetaType();
if (typeId.isValid() && typeId.id() != QMetaType::Void) {
const char *typeName = QDBusMetaType::typeToSignature(typeId);
if (typeName) {
xml += QLatin1String(" <arg type=\"%1\" direction=\"out\"/>\n")
.arg(typeNameToXml(typeName));
// do we need to describe this argument?
if (QDBusMetaType::signatureToType(typeName) == QMetaType::UnknownType)
if (!QDBusMetaType::signatureToMetaType(typeName).isValid())
xml += QLatin1String(" <annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"%1\"/>\n")
.arg(typeNameToXml(QMetaType(typeId).name()));
} else {
qWarning() << "Unsupported return type" << typeId << QMetaType(typeId).name() << "in method" << mm.name();
qWarning() << "Unsupported return type" << typeId.id() << typeId.name() << "in method" << mm.name();
continue;
}
}
else if (typeId == QMetaType::UnknownType) {
else if (!typeId.isValid()) {
qWarning() << "Invalid return type in method" << mm.name();
continue; // wasn't a valid type
}
QList<QByteArray> names = mm.parameterNames();
QList<int> types;
QList<QMetaType> types;
QString errorMsg;
int inputCount = qDBusParametersForMethod(mm, types, errorMsg);
if (inputCount == -1) {
@ -208,7 +208,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
qUtf16Printable(name), signature, isOutput ? "out" : "in");
// do we need to describe this argument?
if (QDBusMetaType::signatureToType(signature) == QMetaType::UnknownType) {
if (!QDBusMetaType::signatureToMetaType(signature).isValid()) {
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"))

View File

@ -80,7 +80,7 @@ static const char help[] =
" -V Show the program version and quit.\n"
"\n";
int qDBusParametersForMethod(const FunctionDef &mm, QList<int> &metaTypes, QString &errorMsg)
int qDBusParametersForMethod(const FunctionDef &mm, QList<QMetaType> &metaTypes, QString &errorMsg)
{
QList<QByteArray> parameterTypes;
parameterTypes.reserve(mm.arguments.size());
@ -107,13 +107,13 @@ static QString addFunction(const FunctionDef &mm, bool isSignal = false) {
int typeId = QMetaType::fromName(mm.normalizedType).id();
if (typeId != QMetaType::Void) {
if (typeId) {
const char *typeName = QDBusMetaType::typeToSignature(typeId);
const char *typeName = QDBusMetaType::typeToSignature(QMetaType(typeId));
if (typeName) {
xml += QString::fromLatin1(" <arg type=\"%1\" direction=\"out\"/>\n")
.arg(typeNameToXml(typeName));
// do we need to describe this argument?
if (QDBusMetaType::signatureToType(typeName) == QMetaType::UnknownType)
if (!QDBusMetaType::signatureToMetaType(typeName).isValid())
xml += QString::fromLatin1(" <annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"%1\"/>\n")
.arg(typeNameToXml(mm.normalizedType.constData()));
} else {
@ -124,7 +124,7 @@ static QString addFunction(const FunctionDef &mm, bool isSignal = false) {
}
}
QList<ArgumentDef> names = mm.arguments;
QList<int> types;
QList<QMetaType> types;
QString errorMsg;
int inputCount = qDBusParametersForMethod(mm, types, errorMsg);
if (inputCount == -1) {
@ -150,14 +150,14 @@ static QString addFunction(const FunctionDef &mm, bool isSignal = false) {
bool isOutput = isSignal || j > inputCount;
const char *signature = QDBusMetaType::typeToSignature(types.at(j));
const char *signature = QDBusMetaType::typeToSignature(QMetaType(types.at(j)));
xml += QString::fromLatin1(" <arg %1type=\"%2\" direction=\"%3\"/>\n")
.arg(name,
QLatin1String(signature),
isOutput ? QLatin1String("out") : QLatin1String("in"));
// do we need to describe this argument?
if (QDBusMetaType::signatureToType(signature) == QMetaType::UnknownType) {
if (!QDBusMetaType::signatureToMetaType(signature).isValid()) {
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"))
@ -214,7 +214,7 @@ static QString generateInterfaceXml(const ClassDef *mo)
mp.type.constData());
continue;
}
const char *signature = QDBusMetaType::typeToSignature(typeId);
const char *signature = QDBusMetaType::typeToSignature(QMetaType(typeId));
if (!signature)
continue;
@ -223,7 +223,7 @@ static QString generateInterfaceXml(const ClassDef *mo)
QLatin1String(signature),
QLatin1String(accessvalues[access]));
if (QDBusMetaType::signatureToType(signature) == QMetaType::UnknownType) {
if (!QDBusMetaType::signatureToMetaType(signature).isValid()) {
retval += QString::fromLatin1(">\n <annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"%3\"/>\n </property>\n")
.arg(typeNameToXml(mp.type.constData()));
} else {

View File

@ -205,7 +205,7 @@ static QString classNameForInterface(const QString &interface, ClassType classTy
// we first search for "Out" and if not found we search for "In"
static QByteArray qtTypeName(const QString &signature, const QDBusIntrospection::Annotations &annotations, int paramId = -1, const char *direction = "Out", bool isSignal = false)
{
int type = QDBusMetaType::signatureToType(signature.toLatin1());
int type = QDBusMetaType::signatureToMetaType(signature.toLatin1()).id();
if (type == QMetaType::UnknownType) {
QString annotationName = QString::fromLatin1("org.qtproject.QtDBus.QtTypeName");
if (paramId >= 0)

View File

@ -386,7 +386,7 @@ inline bool compare(const QDBusArgument &arg, const QVariant &v2, T * = 0)
bool compareToArgument(const QDBusArgument &arg, const QVariant &v2)
{
if (arg.currentSignature() != QDBusMetaType::typeToSignature(v2.userType()))
if (arg.currentSignature() != QDBusMetaType::typeToSignature(v2.metaType()))
return false;
// try to demarshall the arg according to v2
@ -521,7 +521,7 @@ bool compareToArgument(const QDBusArgument &arg, const QVariant &v2)
}
qWarning() << "Unexpected QVariant type" << v2.userType()
<< QByteArray(QDBusMetaType::typeToSignature(v2.userType()))
<< QByteArray(QDBusMetaType::typeToSignature(v2.metaType()))
<< v2.metaType().name();
return false;
}

View File

@ -354,7 +354,7 @@ void tst_QDBusMetaType::staticTypes()
{
QFETCH(QVariant::Type, typeId);
QString result = QDBusMetaType::typeToSignature(typeId);
QString result = QDBusMetaType::typeToSignature(QMetaType(typeId));
QTEST(result, "signature");
}

View File

@ -81,6 +81,7 @@ void tst_qmakelib::proString()
ProString s3("this is a longish string with bells and whistles");
s3 = s3.mid(18, 17);
QCOMPARE(s3.toQString(), QStringLiteral("string with bells"));
// Prepend to detached string with lots of spare space in it.
s3.prepend(ProString("another "));
QCOMPARE(s3.toQString(), QStringLiteral("another string with bells"));