diff options
author | Axel Waggershauser <awagger@gmail.com> | 2013-03-06 17:44:15 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-13 18:40:26 +0100 |
commit | 3c2748afd58ef84d14b028fa43d193addb1add4c (patch) | |
tree | a0eb5d3dcbbc2bf5103ee38dbc04f2beb8fd6afa /tests/auto/corelib/kernel/qobject/tst_qobject.cpp | |
parent | 2f0756a63c699bb67232b535854c8fcbdf2f973c (diff) |
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 <ogoffart@woboq.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'tests/auto/corelib/kernel/qobject/tst_qobject.cpp')
-rw-r--r-- | tests/auto/corelib/kernel/qobject/tst_qobject.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
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(); |