path: root/tests
diff options
authorKent Hansen <>2012-04-26 20:17:33 +0200
committerQt by Nokia <>2012-05-01 20:03:28 +0200
commit74c3517e6afb07ae82fa5b28968a5f18819ea943 (patch)
tree2718616c9c8abd101b4f4bb19ed0fc136e2278e2 /tests
parent3013758f17beecb55bc40d28beef5b55f83dec2a (diff)
Fix regression in connectNotify(const char *) emission
Reimplementations of connectNotify() and disconnectNotify() can assume that the signal argument is in normalized form, but after the introduction of the Qt5 meta-object format, it could happen that it's not. The problem is that the internal QArgumentType class, which attempts to resolve a typename to a type id, was calling QMetaType::type(). QMetaType::type() falls back to trying the normalized form of the typename if the original argument can't be resolved as a type (this behavior isn't documented, but that's how it works). This means that e.g. QMetaType::type("const QString &") returns QMetaType::QString. Since QMetaObjectPrivate::indexOfMethodRelative() (more specifically, the methodMatch() helper function) prefers to compare type ids over typenames (since the type ids are stored directly in the meta- object data for built-in types), the method lookup would *succeed* for signatures with non-normalized built-in typenames as parameters. QObject::connect() would then think that it did not have to normalize the signature (see "// check for normalized signatures"). The consequence was that the original, non-normalized form got passed to connectNotify(). This commit introduces an internal typename-to-type function that is the same as QMetaType::type(), except it doesn't try to normalize the name. This way, the only place where normalization can occur in the signature-to-meta-method processing is through the calls to QMetaObject::normalizedSignature() in QObject::connect() itself. The implication is that there are now cases where the method signature will be decoded and processed twice, where processing it once was sufficient before. On the other hand, it is consistent with the pre-Qt5-meta-object behavior, where we predict that the signature is already normalized, and only perform (comparatively costly) normalization if the initial lookup fails. Change-Id: Ie6b60f60b0f9a57ebd378d980329dac62d57bbd9 Reviewed-by: Jędrzej Nowacki <>
Diffstat (limited to 'tests')
1 files changed, 2 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index fefec5625a..60b92fc27d 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -172,6 +172,7 @@ signals:
void signal4();
QT_MOC_COMPAT void signal5();
void signal6(void);
+ void signal7(int, const QString &);
public slots:
void aPublicSlot() { aPublicSlotCalled++; }
@@ -833,6 +834,7 @@ void tst_QObject::connectDisconnectNotify_data()
QTest::newRow("combo4") << SIGNAL( signal4( void ) )<< SLOT( slot4( void ) );
QTest::newRow("combo5") << SIGNAL( signal6( void ) ) << SLOT( slot4() );
QTest::newRow("combo6") << SIGNAL( signal6() ) << SLOT( slot4() );
+ QTest::newRow("combo7") << SIGNAL( signal7( int , const QString & ) ) << SLOT( slot4() );
void tst_QObject::connectDisconnectNotify()