summaryrefslogtreecommitdiff
path: root/test/signal.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-01-19 04:39:01 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-01-22 17:26:20 +0200
commitb6d93f977239d293bfe0eb7b8fca1c12ff9e18d2 (patch)
tree96177c2d5dfe789db98ecea268e3941e5fee3ea6 /test/signal.cpp
parent0228e9c927351d483fe696e5ca6eea9c2b2cbc87 (diff)
test: signal: Add additional disconnection tests for Object
Add two tests that exercise the Signal::disconnect(Object *) and Signal::disconnect() methods, to verify that they correctly remove the signal from the connected object's list of signals. This triggers an issue that was detected through manual code inspection, and is expected to crash or at least generate valgrind warnings. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'test/signal.cpp')
-rw-r--r--test/signal.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/signal.cpp b/test/signal.cpp
index 0054ed5a..f83ceb05 100644
--- a/test/signal.cpp
+++ b/test/signal.cpp
@@ -220,6 +220,30 @@ protected:
delete dynamicSignal;
delete slotObject;
+ /*
+ * Test that signal manual disconnection from Object removes
+ * the signal for the object. This shall not generate any
+ * valgrind warning.
+ */
+ dynamicSignal = new Signal<>();
+ slotObject = new SlotObject();
+ dynamicSignal->connect(slotObject, &SlotObject::slot);
+ dynamicSignal->disconnect(slotObject);
+ delete dynamicSignal;
+ delete slotObject;
+
+ /*
+ * Test that signal manual disconnection from all slots removes
+ * the signal for the object. This shall not generate any
+ * valgrind warning.
+ */
+ dynamicSignal = new Signal<>();
+ slotObject = new SlotObject();
+ dynamicSignal->connect(slotObject, &SlotObject::slot);
+ dynamicSignal->disconnect();
+ delete dynamicSignal;
+ delete slotObject;
+
/* Exercise the Object slot code paths. */
slotObject = new SlotObject();
signalVoid_.connect(slotObject, &SlotObject::slot);