Remove qDBusNameToTypeId function.
authorJędrzej Nowacki <jedrzej.nowacki@nokia.com>
Thu, 26 Jan 2012 15:54:43 +0000 (16:54 +0100)
committerQt by Nokia <qt-info@nokia.com>
Fri, 27 Jan 2012 09:51:40 +0000 (10:51 +0100)
The function is redundant and can be replaced by QMetaType::type().

Change-Id: I131a7fd285a60d8bd0f3b958668a43bd5da2d6c4
Reviewed-by: Jonas Gastal <jgastal@profusion.mobi>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
src/dbus/qdbusconnection_p.h
src/dbus/qdbusintegrator.cpp
src/dbus/qdbusinternalfilters.cpp
src/dbus/qdbusmisc.cpp
src/dbus/qdbusxmlgenerator.cpp

index 7ad5eca..a089388 100644 (file)
@@ -336,7 +336,6 @@ public:
 
 // in qdbusmisc.cpp
 extern int qDBusParametersForMethod(const QMetaMethod &mm, QList<int>& metaTypes);
-extern int qDBusNameToTypeId(const char *name);
 extern bool qDBusCheckAsyncTag(const char *tag);
 extern bool qDBusInterfaceInObject(QObject *obj, const QString &interface_name);
 extern QString qDBusInterfaceFromMetaObject(const QMetaObject *mo);
index 72739ad..dd8887f 100644 (file)
@@ -645,7 +645,7 @@ static int findSlot(const QMetaObject *mo, const QByteArray &name, int flags,
         if (paren != name.length() || !slotname.startsWith(name))
             continue;
 
-        int returnType = qDBusNameToTypeId(mm.typeName());
+        int returnType = QMetaType::type(mm.typeName());
         bool isAsync = qDBusCheckAsyncTag(mm.tag());
         bool isScriptable = mm.attributes() & QMetaMethod::Scriptable;
 
index 58a048e..30a9c8d 100644 (file)
@@ -324,19 +324,15 @@ static int writeProperty(QObject *obj, const QByteArray &property_name, QVariant
 
     // we found our property
     // do we have the right type?
-    int id = mp.type();
-    if (id == QVariant::UserType) {
-        // dynamic type
-        id = qDBusNameToTypeId(mp.typeName());
-        if (id == -1) {
-            // type not registered?
-            qWarning("QDBusConnection: Unable to handle unregistered datatype '%s' for property '%s::%s'",
-                     mp.typeName(), mo->className(), property_name.constData());
-            return PropertyWriteFailed;
-        }
+    int id = mp.userType();
+    if (!id){
+        // 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 != 0xff && value.userType() == QDBusMetaTypeId::argument) {
+    if (id != QMetaType::QVariant && value.userType() == QDBusMetaTypeId::argument) {
         // we have to demarshall before writing
         void *null = 0;
         QVariant other(id, null);
@@ -434,7 +430,7 @@ static QVariantMap readAllProperties(QObject *object, int flags)
             continue;
 
         // is it a registered property?
-        int typeId = qDBusNameToTypeId(mp.typeName());
+        int typeId = mp.userType();
         if (!typeId)
             continue;
         const char *signature = QDBusMetaType::typeToSignature(typeId);
index 1d40a45..dd5c955 100644 (file)
@@ -69,14 +69,6 @@ bool qDBusCheckAsyncTag(const char *tag)
     return false;
 }
 
-int qDBusNameToTypeId(const char *name)
-{
-    int id = static_cast<int>( QVariant::nameToType(name) );
-    if (id == QVariant::UserType)
-        id = QMetaType::type(name);
-    return id;
-}
-
 QString qDBusInterfaceFromMetaObject(const QMetaObject *mo)
 {
     QString interface;
@@ -158,7 +150,7 @@ int qDBusParametersForMethod(const QMetaMethod &mm, QList<int>& metaTypes)
             QByteArray basictype = type;
             basictype.truncate(type.length() - 1);
 
-            int id = qDBusNameToTypeId(basictype);
+            int id = QMetaType::type(basictype);
             if (id == 0) {
                 //qWarning("Could not parse the method '%s'", mm.signature());
                 // invalid type in method parameter list
@@ -177,7 +169,7 @@ int qDBusParametersForMethod(const QMetaMethod &mm, QList<int>& metaTypes)
             return -1;          // not allowed
         }
 
-        int id = qDBusNameToTypeId(type);
+        int id = QMetaType::type(type);
         if (id == 0) {
             //qWarning("Could not parse the method '%s'", mm.signature());
             // invalid type in method parameter list
index 4e4bff0..1471720 100644 (file)
@@ -101,7 +101,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
             if (mp.isWritable())
                 access |= 2;
 
-            int typeId = qDBusNameToTypeId(mp.typeName());
+            int typeId = mp.userType();
             if (!typeId)
                 continue;
             const char *signature = QDBusMetaType::typeToSignature(typeId);
@@ -150,7 +150,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
                       .arg(QLatin1String(signature.left(paren)));
 
         // check the return type first
-        int typeId = qDBusNameToTypeId(mm.typeName());
+        int typeId = QMetaType::type(mm.typeName());
         if (typeId) {
             const char *typeName = QDBusMetaType::typeToSignature(typeId);
             if (typeName) {