Skip to content

Commit

Permalink
Fix disconnect by slot when slot is wrapped in a
Browse files Browse the repository at this point in the history
boost::reference_wrapper
  • Loading branch information
fmhess committed Dec 30, 2023
1 parent 2ba258f commit 4d994bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/boost/signals2/detail/signal_template.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ namespace boost
void disconnect(const T &slot)
{
typedef mpl::bool_<(is_convertible<T, group_type>::value)> is_group;
do_disconnect(slot, is_group());
do_disconnect(unwrap_ref(slot), is_group());
}
// emit signal
result_type operator ()(BOOST_SIGNALS2_SIGNATURE_FULL_ARGS(BOOST_SIGNALS2_NUM_ARGS))
Expand Down
6 changes: 6 additions & 0 deletions test/signal_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ test_signal_signal_connect()
s1.disconnect(s2);
BOOST_CHECK(s1(3) == -3);

// disconnect by reference wrapped slot
s1.connect(s2);
BOOST_CHECK(s1(3) == 6);
s1.disconnect(boost::ref(s2));
BOOST_CHECK(s1(3) == -3);

// reconnect s2 to test auto-disconnect on destruction
s1.connect(s2);
BOOST_CHECK(s1(3) == 6);
Expand Down

0 comments on commit 4d994bb

Please sign in to comment.