diff options
author | Henrik Kinnunen <fluxgen@fluxbox.org> | 2008-09-21 10:02:49 (GMT) |
---|---|---|
committer | Henrik Kinnunen <fluxgen@fluxbox.org> | 2008-09-21 10:02:49 (GMT) |
commit | f5113e2ec1743d76ac414a020f617917c7933bb7 (patch) | |
tree | a613ba0f36a6d1ac58b5eaeff4121756dc25b4a0 | |
parent | 75cf24da289fa36f18999e23fe549f1c93483428 (diff) | |
download | fluxbox-f5113e2ec1743d76ac414a020f617917c7933bb7.zip fluxbox-f5113e2ec1743d76ac414a020f617917c7933bb7.tar.bz2 |
no virtuals needed Signals, added leaveAll for SignalTracker which must be used before all screens dies.
-rw-r--r-- | src/FbTk/Signal.hh | 35 | ||||
-rw-r--r-- | src/fluxbox.cc | 5 |
2 files changed, 24 insertions, 16 deletions
diff --git a/src/FbTk/Signal.hh b/src/FbTk/Signal.hh index b25fe9a..18b03b3 100644 --- a/src/FbTk/Signal.hh +++ b/src/FbTk/Signal.hh | |||
@@ -46,7 +46,7 @@ public: | |||
46 | typedef Iterator SlotID; | 46 | typedef Iterator SlotID; |
47 | typedef SlotList::const_iterator ConstIterator; | 47 | typedef SlotList::const_iterator ConstIterator; |
48 | 48 | ||
49 | virtual ~SignalHolder() { } | 49 | ~SignalHolder() { } |
50 | 50 | ||
51 | /// Remove a specific slot \c id from this signal | 51 | /// Remove a specific slot \c id from this signal |
52 | void disconnect(SlotID slotIt) { | 52 | void disconnect(SlotID slotIt) { |
@@ -81,7 +81,7 @@ class Signal0: public SignalHolder { | |||
81 | public: | 81 | public: |
82 | typedef Slot0<ReturnType> SlotType; | 82 | typedef Slot0<ReturnType> SlotType; |
83 | 83 | ||
84 | virtual ~Signal0() { } | 84 | ~Signal0() { } |
85 | 85 | ||
86 | void emit() { | 86 | void emit() { |
87 | for ( Iterator it = begin(); it != end(); ++it ) { | 87 | for ( Iterator it = begin(); it != end(); ++it ) { |
@@ -101,7 +101,7 @@ class Signal1: public SignalHolder { | |||
101 | public: | 101 | public: |
102 | typedef Slot1<ReturnType, Arg1> SlotType; | 102 | typedef Slot1<ReturnType, Arg1> SlotType; |
103 | 103 | ||
104 | virtual ~Signal1() { } | 104 | ~Signal1() { } |
105 | 105 | ||
106 | void emit(Arg1 arg) { | 106 | void emit(Arg1 arg) { |
107 | for ( Iterator it = begin(); it != end(); ++it ) { | 107 | for ( Iterator it = begin(); it != end(); ++it ) { |
@@ -121,7 +121,7 @@ class Signal2: public SignalHolder { | |||
121 | public: | 121 | public: |
122 | typedef Slot2<ReturnType, Arg1, Arg2> SlotType; | 122 | typedef Slot2<ReturnType, Arg1, Arg2> SlotType; |
123 | 123 | ||
124 | virtual ~Signal2() { } | 124 | ~Signal2() { } |
125 | 125 | ||
126 | void emit(Arg1 arg1, Arg2 arg2) { | 126 | void emit(Arg1 arg1, Arg2 arg2) { |
127 | for ( Iterator it = begin(); it != end(); ++it ) { | 127 | for ( Iterator it = begin(); it != end(); ++it ) { |
@@ -140,7 +140,7 @@ class Signal3: public SignalHolder { | |||
140 | public: | 140 | public: |
141 | typedef Slot3<ReturnType, Arg1, Arg2, Arg3> SlotType; | 141 | typedef Slot3<ReturnType, Arg1, Arg2, Arg3> SlotType; |
142 | 142 | ||
143 | virtual ~Signal3() { } | 143 | ~Signal3() { } |
144 | 144 | ||
145 | void emit(Arg1 arg1, Arg2 arg2, Arg3 arg3) { | 145 | void emit(Arg1 arg1, Arg2 arg2, Arg3 arg3) { |
146 | for ( Iterator it = begin(); it != end(); ++it ) { | 146 | for ( Iterator it = begin(); it != end(); ++it ) { |
@@ -191,15 +191,12 @@ public: | |||
191 | class SignalTracker { | 191 | class SignalTracker { |
192 | public: | 192 | public: |
193 | /// Internal type, do not use. | 193 | /// Internal type, do not use. |
194 | typedef std::map<SigImpl::SignalHolder*, SigImpl::SignalHolder::SlotID> Connections; | 194 | typedef std::list< std::pair<SigImpl::SignalHolder*, |
195 | SigImpl::SignalHolder::SlotID> > Connections; | ||
195 | typedef Connections::iterator TrackID; ///< \c ID type for join/leave. | 196 | typedef Connections::iterator TrackID; ///< \c ID type for join/leave. |
196 | 197 | ||
197 | virtual ~SignalTracker() { | 198 | ~SignalTracker() { |
198 | // disconnect all connections | 199 | leaveAll(); |
199 | for ( Connections::iterator conIt = m_connections.begin(); | ||
200 | conIt != m_connections.end(); ++conIt) | ||
201 | conIt->first->disconnect( conIt->second ); | ||
202 | m_connections.clear(); | ||
203 | } | 200 | } |
204 | 201 | ||
205 | /// Starts tracking a signal. | 202 | /// Starts tracking a signal. |
@@ -220,10 +217,22 @@ public: | |||
220 | /// Leave tracking for a signal | 217 | /// Leave tracking for a signal |
221 | /// @param sig the signal to leave | 218 | /// @param sig the signal to leave |
222 | template <typename Signal> | 219 | template <typename Signal> |
223 | void leave(Signal &sig) { | 220 | void leave(const Signal &sig) { |
224 | m_connections.erase(&sig); | 221 | m_connections.erase(&sig); |
225 | } | 222 | } |
226 | 223 | ||
224 | |||
225 | void leaveAll() { | ||
226 | // disconnect all connections | ||
227 | for ( Connections::iterator conIt = m_connections.begin(); | ||
228 | conIt != m_connections.end(); ) { | ||
229 | // keep temporary, while disconnecting we can | ||
230 | // in some strange cases get a call to this again | ||
231 | Connections::value_type tmp = *conIt; | ||
232 | conIt = m_connections.erase(conIt); | ||
233 | tmp.first->disconnect(tmp.second); | ||
234 | } | ||
235 | } | ||
227 | private: | 236 | private: |
228 | /// holds all connections to different signals and slots. | 237 | /// holds all connections to different signals and slots. |
229 | Connections m_connections; | 238 | Connections m_connections; |
diff --git a/src/fluxbox.cc b/src/fluxbox.cc index fa68d00..9e62ac3 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc | |||
@@ -427,11 +427,10 @@ Fluxbox::~Fluxbox() { | |||
427 | // key commands cause a segfault when the XLayerItem is destroyed | 427 | // key commands cause a segfault when the XLayerItem is destroyed |
428 | m_key.reset(0); | 428 | m_key.reset(0); |
429 | 429 | ||
430 | leaveAll(); // leave all connections | ||
431 | |||
430 | // destroy screens (after others, as they may do screen things) | 432 | // destroy screens (after others, as they may do screen things) |
431 | while (!m_screen_list.empty()) { | 433 | while (!m_screen_list.empty()) { |
432 | // this needs to be done before the signal is destroyed | ||
433 | leave( m_screen_list.back()->workspaceCountSig() ); | ||
434 | |||
435 | delete m_screen_list.back(); | 434 | delete m_screen_list.back(); |
436 | m_screen_list.pop_back(); | 435 | m_screen_list.pop_back(); |
437 | } | 436 | } |