diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2012-02-18 23:16:24 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-29 12:50:14 +0100 |
commit | 96f2365cf4cebc074c3171878dcd25ce19ee7486 (patch) | |
tree | 188bde357226f7c86adf11618bbaac8e53020f97 /src/testlib/qtestcase.cpp | |
parent | 3f7a222414fc9d3e9f2e2cfdd05f33740c5afb7e (diff) |
Rename QMetaMethod::signature() to methodSignature()
In Qt5 the meta-data format will be changed to not store the
method signature string explicitly; the signature will be
reconstructed on demand from the method name and parameter type
information.
The QMetaMethod::signature() method returns a const char pointer.
Changing the return type to QByteArray can lead to silent bugs due to
the implicit conversion to char *. Even though it's a source-
incompatible change, it's therefore better to introduce a new
function, methodSignature(), and remove the old signature().
Task-number: QTBUG-24154
Change-Id: Ib3579dedd27a3c7c8914d5f1b231947be2cf4027
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Diffstat (limited to 'src/testlib/qtestcase.cpp')
-rw-r--r-- | src/testlib/qtestcase.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index a4f1a39bbd..d02f449d70 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1061,7 +1061,8 @@ static bool isValidSlot(const QMetaMethod &sl) if (sl.access() != QMetaMethod::Private || !sl.parameterTypes().isEmpty() || qstrlen(sl.typeName()) || sl.methodType() != QMetaMethod::Slot) return false; - const char *sig = sl.signature(); + QByteArray signature = sl.methodSignature(); + const char *sig = signature.constData(); int len = qstrlen(sig); if (len < 2) return false; @@ -1084,7 +1085,7 @@ static void qPrintTestSlots(FILE *stream) for (int i = 0; i < QTest::currentTestObject->metaObject()->methodCount(); ++i) { QMetaMethod sl = QTest::currentTestObject->metaObject()->method(i); if (isValidSlot(sl)) - fprintf(stream, "%s\n", sl.signature()); + fprintf(stream, "%s\n", sl.methodSignature().constData()); } } @@ -1109,7 +1110,7 @@ static void qPrintDataTags(FILE *stream) // Retrieve local tags: QStringList localTags; QTestTable table; - char *slot = qstrdup(tf.signature()); + char *slot = qstrdup(tf.methodSignature().constData()); slot[strlen(slot) - 2] = '\0'; QByteArray member; member.resize(qstrlen(slot) + qstrlen("_data()") + 1); @@ -1779,7 +1780,7 @@ static void qInvokeTestMethods(QObject *testObject) if (QTest::testFuncs) { for (int i = 0; i != QTest::testFuncCount; i++) { - if (!qInvokeTestMethod(metaObject->method(QTest::testFuncs[i].function()).signature(), + if (!qInvokeTestMethod(metaObject->method(QTest::testFuncs[i].function()).methodSignature().constData(), QTest::testFuncs[i].data())) { break; } @@ -1793,7 +1794,7 @@ static void qInvokeTestMethods(QObject *testObject) for (int i = 0; i != methodCount; i++) { if (!isValidSlot(testMethods[i])) continue; - if (!qInvokeTestMethod(testMethods[i].signature())) + if (!qInvokeTestMethod(testMethods[i].methodSignature().constData())) break; } delete[] testMethods; |