diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2016-05-29 17:45:05 -0300 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2016-05-30 00:19:39 +0000 |
commit | 32c301e2296c5b3ba31528e6d92b521d43a216e9 (patch) | |
tree | fabce68c87fed9e62346f2a1e4ac3efca83bad76 /tests | |
parent | 6d31d3e7effabcc998792283249d46f5c0d73b3d (diff) |
Fix crash when connecting a non-PMF with Qt::UniqueConnection...
...if a PMF connection had already happened. Since UniqueConnection
isn't implemented for non-PMFs (functors and lambdas aren't comparable,
even if static member functions or non-member functions are), we pass a
null pointer for comparison argument. The disconnect() code already
protected against a null pointer there, but not the connect code path
with Qt::UniqueConnection
Change-Id: I87e17314d8b24ae983b1fffd145324beced0494d
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Dario Freddi <dario.freddi@ispirata.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/kernel/qobject/tst_qobject.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 5b89ef3792..46889225eb 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -139,6 +139,7 @@ private slots: void connectFunctorOverloads(); void connectFunctorQueued(); void connectFunctorWithContext(); + void connectFunctorWithContextUnique(); void connectFunctorDeadlock(); void connectStaticSlotWithObject(); void disconnectDoesNotLeakFunctor(); @@ -5800,6 +5801,22 @@ void tst_QObject::connectFunctorWithContext() context->deleteLater(); } +void tst_QObject::connectFunctorWithContextUnique() +{ + // Qt::UniqueConnections currently don't work for functors, but we need to + // be sure that they don't crash. If that is implemented, change this test. + + SenderObject sender; + ReceiverObject receiver; + QObject::connect(&sender, &SenderObject::signal1, &receiver, &ReceiverObject::slot1); + receiver.count_slot1 = 0; + + QObject::connect(&sender, &SenderObject::signal1, &receiver, SlotFunctor(), Qt::UniqueConnection); + + sender.emitSignal1(); + QCOMPARE(receiver.count_slot1, 1); +} + class MyFunctor { public: |