qt5base-lts/tests/auto/corelib/kernel
Giuseppe D'Angelo 11b8c46d2a QObject: add a single shot connection flag
If one needed to listen to a signal just once, one had to
store the QMetaObject::Connection object returned by connect()
and use it to disconnect the slot after the first signal
activation.

This has led to a proliferation of using wrappers (and enough
TMP); they usually look like this:

1) create a shared_ptr<QMO::Connection>, allocating its payload;
2) create a lambda, capturing the shared_ptr by value;
3) in the lambda, disconnect the connection (through the shared_ptr),
   and call the actual slot;
4) connect the signal to the lambda, storing the returned
   QMO::Connection into the shared_ptr.

This is expensive, error prone for newcomers, and tricky to
support as a general facility inside one's projects.
We can do better, just support single shot connections right
in QObject.

[ChangeLog][QtCore][QObject] Added the Qt::SingleShotConnection
flag. When a connection is established with this flag set,
the slot is going to be activated at most once; when the signal
is emitted, the connection gets automatically broken by Qt.

Change-Id: I5f5feeae7f76c9c3d6323d841efba81c8f98ce7e
Fixes: QTBUG-44219
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-09-01 17:59:36 +02:00
..
qcoreapplication Remove winrt 2020-06-06 20:25:49 +02:00
qdeadlinetimer CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qelapsedtimer CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qeventdispatcher Synchronize QEventDispatcherWin32::processEvents() with QCoreApplication 2020-08-26 11:08:15 +03:00
qeventloop CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qmath CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qmetacontainer Add a QMetaSequence interface 2020-09-01 13:35:39 +02:00
qmetaenum CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qmetamethod Improve connect: Use existing metatypes if possible 2020-08-28 00:41:00 +02:00
qmetaobject Deprecate the static int based API in QMetaType 2020-08-24 00:19:05 +02:00
qmetaobjectbuilder CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qmetaproperty Deprecate the static int based API in QMetaType 2020-08-24 00:19:05 +02:00
qmetatype QWeakPointer: purge deprecated API 2020-08-31 10:32:39 +02:00
qmimedata CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qobject QObject: add a single shot connection flag 2020-09-01 17:59:36 +02:00
qpointer CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qproperty QNotifiedProperty: avoid crash 2020-08-04 11:28:33 +00:00
qsharedmemory CMake: Regenerate subdir test projects 2020-07-09 09:38:39 +02:00
qsignalblocker CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qsignalmapper CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qsocketnotifier CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qsystemsemaphore CMake: Regenerate subdir test projects 2020-07-09 09:38:39 +02:00
qtimer CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qtranslator Make QTranslator::load() insist that its return value be checked 2020-08-28 21:26:21 +02:00
qvariant QWeakPointer: purge deprecated API 2020-08-31 10:32:39 +02:00
qwineventnotifier CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
.prev_CMakeLists.txt Add a QMetaSequence interface 2020-09-01 13:35:39 +02:00
CMakeLists.txt Add a QMetaSequence interface 2020-09-01 13:35:39 +02:00
kernel.pro Add a QMetaSequence interface 2020-09-01 13:35:39 +02:00