From 22d621dd99417be289b311e3fea5a24f385596fb Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 20 Mar 2012 19:27:02 +0100 Subject: QMetaMethod::typeName() should return "void" if the return type is void MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Olivier Goffart Reviewed-by: Lars Knoll --- dist/changes-5.0.0 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'dist') 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 -- cgit v1.2.3