Force deletion of slot in boost::signals2

前端 未结 5 1166
清歌不尽
清歌不尽 2021-02-05 20:13

I have found that boost::signals2 uses sort of a lazy deletion of connected slots, which makes it difficult to use connections as something that manages lifetimes of objects. I

5条回答
  •  滥情空心
    2021-02-05 20:58

    This is an incredibly annoying aspect of boost::signals2.

    The approach I took to resolve it is to store the signal in a scoped_ptr, and when I want to force disconnection of all slots, I delete the signal. This only works in cases when you want to forcefully disconnect all connections to a signal.

提交回复
热议问题