QMetaMethod::invoke: Use normalizedType() to normalize return type
authorKent Hansen <kent.hansen@nokia.com>
Fri, 15 Jun 2012 10:23:00 +0000 (12:23 +0200)
committerQt by Nokia <qt-info@nokia.com>
Wed, 20 Jun 2012 07:34:40 +0000 (09:34 +0200)
The code was probably written before QMetaObject::normalizedType()
was introduced.

The behavior is covered by the existing tests
tst_QMetaObject::invokeMetaMember and
tst_QMetaObject::invokeBlockingQueuedMetaMember.

Change-Id: Ib1c3b3e4dff37947defd1dfdcc860df44539aa3a
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
src/corelib/kernel/qmetaobject.cpp

index 417c49b..3e82de7 100644 (file)
@@ -2056,20 +2056,8 @@ bool QMetaMethod::invoke(QObject *object,
         const char *retType = typeName();
         if (qstrcmp(returnValue.name(), retType) != 0) {
             // normalize the return value as well
-            // the trick here is to make a function signature out of the return type
-            // so that we can call normalizedSignature() and avoid duplicating code
-            QByteArray unnormalized;
-            int len = qstrlen(returnValue.name());
-
-            unnormalized.reserve(len + 3);
-            unnormalized = "_(";        // the function is called "_"
-            unnormalized.append(returnValue.name());
-            unnormalized.append(')');
-
-            QByteArray normalized = QMetaObject::normalizedSignature(unnormalized.constData());
-            normalized.truncate(normalized.length() - 1); // drop the ending ')'
-
-            if (qstrcmp(normalized.constData() + 2, retType) != 0)
+            QByteArray normalized = QMetaObject::normalizedType(returnValue.name());
+            if (qstrcmp(normalized.constData(), retType) != 0)
                 return false;
         }
     }