|author||Kent Hansen <firstname.lastname@example.org>||2012-03-20 19:27:02 +0100|
|committer||Qt by Nokia <email@example.com>||2012-03-21 18:55:51 +0100|
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 <firstname.lastname@example.org> Reviewed-by: Olivier Goffart <email@example.com> Reviewed-by: Lars Knoll <firstname.lastname@example.org>
Diffstat (limited to 'dist')
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
@@ -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::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.
* The plain-text, xml and lightxml test output formats have been changed to