Boost logo

Boost Users :

Subject: [Boost-users] Closure not destructed properly when signals2 connection is closed.
From: Paul Blampspied (elpidiovaldez5_at_[hidden])
Date: 2016-12-03 01:40:55


Am I right in thinking that when a signal is connected to a closure created
by boost::bind, then the closure should be destructed when the connection
is closed ?

I am having trouble because I pass a boost::shared_ptr in the closure. The
use count does not drop when the signal connection is closed (the signal is
connected to a one-shot slot which closes the connection). As a result the
shared_ptr never deletes its data causing a memory leak.

I have seen a few mentions of bugs in signals2 with respect to object
destruction on connection termination. Perhaps I have fallen foul of
that. It seems quite a serious bug though considering the general standard
of boost.

Given that the one-shot slot receives the shared_ptr I am considering a
hack to fix the problem - explicitly break into the shared_ptr and
decrement the reference count that I believe should be decremented by
conn.disconnect(). Is there a better way ?



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net