Slot is not deleted when the disconnected is first in list
jkalmar opened this issue · comments
I have been playing with your lib and found that if you connect one slot, then the tracked object goes out of scope and if the slot was the first in m_slots it is not released.
Shouldn't the
template< typename ... A > void operator()( A && ... a )
in the case the slot is disconnected and also is the first null the m_slots like this:
else
{
// curr is marked as disconnected
if( prev )
{
( *prev )->next = ( *curr )->next;
curr = ( *prev )->next ? &( ( *prev )->next ) : nullptr;
}
else
{
curr = ( *curr )->next ? &( ( *curr )->next ) : nullptr;
m_slots = curr ? *curr : nullptr;
}
}
I did this change and it looks that it works ok and also the slot is released from memory
Thank you for this bug report.
You are entirely right, the pointer was incremented but m_slots not updated. I actually had code lying around locally that accidentally fixed this bug, so I went ahead and pushed it.
I also added a few unit tests that trigger this bug, to it should be fine now.
I close the bug, tell me if you observe any regression.