From 16c90dc19fcd68fccbcfb277b3839e7f41fe9dd3 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Sun, 8 May 2011 00:04:12 +0200 Subject: 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. --- src/FbTk/Signal.hh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/FbTk/Signal.hh b/src/FbTk/Signal.hh index a7b91ba..0148a17 100644 --- a/src/FbTk/Signal.hh +++ b/src/FbTk/Signal.hh @@ -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()); } } -- cgit v0.11.2