From f5113e2ec1743d76ac414a020f617917c7933bb7 Mon Sep 17 00:00:00 2001 From: Henrik Kinnunen Date: Sun, 21 Sep 2008 12:02:49 +0200 Subject: no virtuals needed Signals, added leaveAll for SignalTracker which must be used before all screens dies. --- src/FbTk/Signal.hh | 35 ++++++++++++++++++++++------------- 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: typedef Iterator SlotID; typedef SlotList::const_iterator ConstIterator; - virtual ~SignalHolder() { } + ~SignalHolder() { } /// Remove a specific slot \c id from this signal void disconnect(SlotID slotIt) { @@ -81,7 +81,7 @@ class Signal0: public SignalHolder { public: typedef Slot0 SlotType; - virtual ~Signal0() { } + ~Signal0() { } void emit() { for ( Iterator it = begin(); it != end(); ++it ) { @@ -101,7 +101,7 @@ class Signal1: public SignalHolder { public: typedef Slot1 SlotType; - virtual ~Signal1() { } + ~Signal1() { } void emit(Arg1 arg) { for ( Iterator it = begin(); it != end(); ++it ) { @@ -121,7 +121,7 @@ class Signal2: public SignalHolder { public: typedef Slot2 SlotType; - virtual ~Signal2() { } + ~Signal2() { } void emit(Arg1 arg1, Arg2 arg2) { for ( Iterator it = begin(); it != end(); ++it ) { @@ -140,7 +140,7 @@ class Signal3: public SignalHolder { public: typedef Slot3 SlotType; - virtual ~Signal3() { } + ~Signal3() { } void emit(Arg1 arg1, Arg2 arg2, Arg3 arg3) { for ( Iterator it = begin(); it != end(); ++it ) { @@ -191,15 +191,12 @@ public: class SignalTracker { public: /// Internal type, do not use. - typedef std::map Connections; + typedef std::list< std::pair > Connections; typedef Connections::iterator TrackID; ///< \c ID type for join/leave. - virtual ~SignalTracker() { - // disconnect all connections - for ( Connections::iterator conIt = m_connections.begin(); - conIt != m_connections.end(); ++conIt) - conIt->first->disconnect( conIt->second ); - m_connections.clear(); + ~SignalTracker() { + leaveAll(); } /// Starts tracking a signal. @@ -220,10 +217,22 @@ public: /// Leave tracking for a signal /// @param sig the signal to leave template - void leave(Signal &sig) { + void leave(const Signal &sig) { m_connections.erase(&sig); } + + void leaveAll() { + // disconnect all connections + for ( Connections::iterator conIt = m_connections.begin(); + conIt != m_connections.end(); ) { + // keep temporary, while disconnecting we can + // in some strange cases get a call to this again + Connections::value_type tmp = *conIt; + conIt = m_connections.erase(conIt); + tmp.first->disconnect(tmp.second); + } + } private: /// holds all connections to different signals and slots. 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() { // key commands cause a segfault when the XLayerItem is destroyed m_key.reset(0); + leaveAll(); // leave all connections + // destroy screens (after others, as they may do screen things) while (!m_screen_list.empty()) { - // this needs to be done before the signal is destroyed - leave( m_screen_list.back()->workspaceCountSig() ); - delete m_screen_list.back(); m_screen_list.pop_back(); } -- cgit v0.11.2