diff options
author | Pavel Labath <pavelo@centrum.sk> | 2011-05-07 22:04:12 (GMT) |
---|---|---|
committer | Pavel Labath <pavelo@centrum.sk> | 2011-05-10 11:00:46 (GMT) |
commit | 16c90dc19fcd68fccbcfb277b3839e7f41fe9dd3 (patch) | |
tree | 8a024b6316ab3a96b8aab334eef3f2c21377869d | |
parent | 7525ca9f7745a7d8ef4461dc1f3c911498546b00 (diff) | |
download | fluxbox_paul-16c90dc19fcd68fccbcfb277b3839e7f41fe9dd3.zip fluxbox_paul-16c90dc19fcd68fccbcfb277b3839e7f41fe9dd3.tar.bz2 |
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.
-rw-r--r-- | src/FbTk/Signal.hh | 7 |
1 files 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: | |||
216 | 216 | ||
217 | /// Leave tracking for a signal | 217 | /// Leave tracking for a signal |
218 | /// @param id the \c id from the previous \c join | 218 | /// @param id the \c id from the previous \c join |
219 | void leave(TrackID id, bool withTracker = false) { | 219 | void leave(TrackID id) { |
220 | // keep temporary, while disconnecting we can | 220 | // keep temporary, while disconnecting we can |
221 | // in some strange cases get a call to this again | 221 | // in some strange cases get a call to this again |
222 | ValueType tmp = *id; | 222 | ValueType tmp = *id; |
223 | m_connections.erase(id); | 223 | m_connections.erase(id); |
224 | tmp.first->disconnect(tmp.second); | 224 | tmp.first->disconnect(tmp.second); |
225 | if (withTracker) | 225 | tmp.first->disconnectTracker(*this); |
226 | tmp.first->disconnectTracker(*this); | ||
227 | } | 226 | } |
228 | 227 | ||
229 | /// Leave tracking for a signal | 228 | /// Leave tracking for a signal |
@@ -240,7 +239,7 @@ public: | |||
240 | void leaveAll() { | 239 | void leaveAll() { |
241 | // disconnect all connections | 240 | // disconnect all connections |
242 | for ( ; !m_connections.empty(); ) { | 241 | for ( ; !m_connections.empty(); ) { |
243 | leave(m_connections.begin(), true); | 242 | leave(m_connections.begin()); |
244 | } | 243 | } |
245 | } | 244 | } |
246 | 245 | ||