util: fix segfault in UtilSignal/DisconnectSelfInHandler test case
refs #2302
Change-Id: I354c39b3ebdef2ed0f0403c15448e23856ab47b3
diff --git a/tests/unit-tests/util/signal.cpp b/tests/unit-tests/util/signal.cpp
index 0de06a2..afb4980 100644
--- a/tests/unit-tests/util/signal.cpp
+++ b/tests/unit-tests/util/signal.cpp
@@ -286,11 +286,13 @@
int hit = 0;
Connection connection;
- connection = so.sig.connect([&] {
+ connection = so.sig.connect(bind([&] (SignalOwner0& so) {
++hit;
connection.disconnect();
BOOST_CHECK_EQUAL(so.isSigEmpty(), false); // disconnecting hasn't taken effect
- });
+ }, ref(so)));
+ // Bug 2302: 'so' needs to be bound to the handler;
+ // lambda capture won't work because closure would be destructed at .disconnect
so.emitSignal(sig);
BOOST_CHECK_EQUAL(hit, 1); // handler called