From 3c2748afd58ef84d14b028fa43d193addb1add4c Mon Sep 17 00:00:00 2001 From: Axel Waggershauser Date: Wed, 6 Mar 2013 17:44:15 +0100 Subject: Improve warning messages (and readability) of connectSlotsByName() While adding a test case for the new behavior, two issues with the connectSlotsByName implementation came up: 1. for auto-connected slots that don't exactly match a signal, a 'compatible' one is searched. There might be more than one of those. The implementation randomly picks any. 2. The "No matching signal for %s" warning gets printed even for slots that can never be connected via connectSlotsMyName anyway (e.g. "on_something"). This is inconsistent. This fixed both: an explicit warning is printed if more than one 'compatible' signal is found and the "No matching signal for %s" warning is only printed if the slot adheres to the full "on_child_signal()" naming convention. In the process I added comments and changed the code slightly to make it more readable and explicitly hint at non-obvious behavior. Change-Id: Icc8e3b9936188d2da8dfff9f0373c8e5c776eb14 Reviewed-by: Olivier Goffart Reviewed-by: Friedemann Kleint --- tests/auto/corelib/kernel/qobject/tst_qobject.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/auto/corelib/kernel/qobject/tst_qobject.cpp') diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index db21ab4fe4..dd88d863c9 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -427,6 +427,9 @@ public slots: protected slots: void o() { called_slots << -1; } void on() { called_slots << -1; } + void on_() { called_slots << -1; } + void on_something() { called_slots << -1; } + void on_child_signal() { called_slots << -1; } signals: void on_Sender_signalLoopBack(); @@ -441,6 +444,8 @@ void tst_QObject::connectSlotsByName() AutoConnectSender sender(&receiver); sender.setObjectName("Sender"); + QTest::ignoreMessage(QtWarningMsg, "QMetaObject::connectSlotsByName: No matching signal for on_child_signal()"); + QTest::ignoreMessage(QtWarningMsg, "QMetaObject::connectSlotsByName: Connecting slot on_Sender_signalManyParams() with the first of the following compatible signals: (\"signalManyParams(int,int,int,QString,bool)\", \"signalManyParams(int,int,int,QString,bool,bool)\") "); QMetaObject::connectSlotsByName(&receiver); receiver.called_slots.clear(); -- cgit v1.2.3