diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2012-03-20 19:27:02 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-21 18:55:51 +0100 |
commit | 22d621dd99417be289b311e3fea5a24f385596fb (patch) | |
tree | 8fd506e6c57a9cfd1efeccb0305b19dee0879e07 /dist | |
parent | b8d71ed60ba57142237555edb97d4cc7d3675b5c (diff) |
QMetaMethod::typeName() should return "void" if the return type is void
QMetaMethod::typeName() is documented to return an empty string if
the return type is void. But after the introduction of
QMetaType::UnknownType (where void was made a distinct type),
returning an empty string causes the idiom
QMetaType::type(method.typeName())
to break; the result will be QMetaType::UnknownType rather than
the expected QMetaType::Void for methods that return void.
New code should use the new function QMetaMethod::returnType()
instead, but it would be good if existing code still did the right
thing.
The consequence of returning "void" instead of an empty string is
that it breaks existing logic that uses the typeName() length to
determine whether a method returns void. But we judge this as the
lesser of the two evils; it's better to have a typeName() function
that is consistent and keeps the QMetaType::type(method.typeName())
idiom working, than to force the typeName() inconsistency for void
only to keep code that does "strlen(method.typeName()) == 0"
working.
The places in Qt that were relying on a zero-length typeName()
(testlib, dbus, declarative) have already been changed to use
returnType().
Also adapt QMetaObjectBuilder, which is internal API.
Change-Id: I70249174029811c5b5d2a08c24b6db33b3723d19
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'dist')
-rw-r--r-- | dist/changes-5.0.0 | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0 index 0897d4937e..ab9b80c21d 100644 --- a/dist/changes-5.0.0 +++ b/dist/changes-5.0.0 @@ -58,10 +58,15 @@ information about a particular change. * QMetaType::construct() has been renamed to QMetaType::create(). * QMetaType::unregisterType() has been removed. -- QMetaMethod::signature() has been renamed to QMetaMethod::methodSignature(), - and the return type has been changed to QByteArray. This was done to be able - to generate the signature string on demand, rather than always storing it in - the meta-data. +- QMetaMethod: + * QMetaMethod::signature() has been renamed to QMetaMethod::methodSignature(), + and the return type has been changed to QByteArray. This was done to be able + to generate the signature string on demand, rather than always storing it in + the meta-data. + * QMetaMethod::typeName() no longer returns an empty string when the return + type is void; it returns "void". The recommended way of checking whether a + method returns void is to compare the return value of QMetaMethod::returnType() + to QMetaType::Void. - QTestLib: * The plain-text, xml and lightxml test output formats have been changed to |