summaryrefslogtreecommitdiff
path: root/src/libcamera/base/signal.cpp
diff options
context:
space:
mode:
authorKieran Bingham <kieran.bingham@ideasonboard.com>2022-01-19 00:17:17 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2022-02-04 10:13:29 +0000
commit7653021549583a58660d46e3d160c82f58f22c69 (patch)
treec0f131cbe7c0387af727b6b58ff8587ac9bbdc93 /src/libcamera/base/signal.cpp
parent20272b9b188fb1f9c8f4125806c8a2c7f141b389 (diff)
libcamera: base: object: Prevent the same signal being connected more than once
Objects are not expected to be connected to the same signal more than once. Doing so likely indicates a bug in the code, and can be highlighted in debug builds with an assert that performs a lookup on the signals_ list. While it is possible to allow the implementation to let objects connect to a specific signal multiple times, there are no expected use cases for this in libcamera and this behaviour is restricted to favour defensive programming by raising an error when this occurs. Remove the support in the test framework which uses multiple Signal connections on the same object, and update the test to use a second Signal. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/libcamera/base/signal.cpp')
-rw-r--r--src/libcamera/base/signal.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/libcamera/base/signal.cpp b/src/libcamera/base/signal.cpp
index 9df45d07..a46386a0 100644
--- a/src/libcamera/base/signal.cpp
+++ b/src/libcamera/base/signal.cpp
@@ -93,9 +93,7 @@ SignalBase::SlotList SignalBase::slots()
* Connecting a signal to a slot results in the slot being called with the
* arguments passed to the emit() function when the signal is emitted. Multiple
* slots can be connected to the same signal, and multiple signals can connected
- * to the same slot. Duplicate connections between a signal and a slot are
- * allowed and result in the slot being called multiple times for the same
- * signal emission.
+ * to the same slot.
*
* When a slot belongs to an instance of the Object class, the slot is called
* in the context of the thread that the object is bound to. If the signal is
@@ -105,6 +103,9 @@ SignalBase::SlotList SignalBase::slots()
* loop, after the Signal::emit() function returns, with a copy of the signal's
* arguments. The emitter shall thus ensure that any pointer or reference
* passed through the signal will remain valid after the signal is emitted.
+ *
+ * Duplicate connections between a signal and a slot are not expected and use of
+ * the Object class to manage signals will enforce this restriction.
*/
/**