Make SignalTracker always disconnect itself from Signals

previously, the tracker disconnected itself only when the caller passed withTracker = true to the
leave() function. However, the default value was for the parameter was false.

Non disconnecting from signal when stopping tracking creates very dangerous situation because the
signal still holds a pointer to the tracker. This resulted in a segfault when exiting fluxbox,
because the tracker (FluxboxWindow) got destroyed before the signal (BScreen::focusedWindowSig),
and the signal was using an invalid pointer when it tried to disconnect itself from the tracker.

Instead of setting withTracker to true by default or changing all invocations of leave(), I
decided to make the tracker disconnect itself unconditionally because I could not find a use case
for the opposite behaviour.

PS: This message is in fact longer than the actual commit.
This commit is contained in:
Pavel Labath 2011-05-08 00:04:12 +02:00
parent 7525ca9f77
commit 16c90dc19f

View file

@ -216,14 +216,13 @@ public:
/// Leave tracking for a signal
/// @param id the \c id from the previous \c join
void leave(TrackID id, bool withTracker = false) {
void leave(TrackID id) {
// keep temporary, while disconnecting we can
// in some strange cases get a call to this again
ValueType tmp = *id;
m_connections.erase(id);
tmp.first->disconnect(tmp.second);
if (withTracker)
tmp.first->disconnectTracker(*this);
tmp.first->disconnectTracker(*this);
}
/// Leave tracking for a signal
@ -240,7 +239,7 @@ public:
void leaveAll() {
// disconnect all connections
for ( ; !m_connections.empty(); ) {
leave(m_connections.begin(), true);
leave(m_connections.begin());
}
}