From 4c11204716c3e31d853cb071239cafea52a92efc Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Sat, 20 Sep 2008 23:46:23 -0700 Subject: fix a few things with new signal code --- src/FbTk/Signal.hh | 27 ++++++++++++++++++++++----- src/fluxbox.cc | 3 +++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/FbTk/Signal.hh b/src/FbTk/Signal.hh index 768ca90..b25fe9a 100644 --- a/src/FbTk/Signal.hh +++ b/src/FbTk/Signal.hh @@ -24,6 +24,7 @@ #include "Slot.hh" #include +#include #include namespace FbTk { @@ -45,6 +46,8 @@ public: typedef Iterator SlotID; typedef SlotList::const_iterator ConstIterator; + virtual ~SignalHolder() { } + /// Remove a specific slot \c id from this signal void disconnect(SlotID slotIt) { m_slots.erase( slotIt ); @@ -78,6 +81,8 @@ class Signal0: public SignalHolder { public: typedef Slot0 SlotType; + virtual ~Signal0() { } + void emit() { for ( Iterator it = begin(); it != end(); ++it ) { static_cast(*it)(); @@ -96,6 +101,8 @@ class Signal1: public SignalHolder { public: typedef Slot1 SlotType; + virtual ~Signal1() { } + void emit(Arg1 arg) { for ( Iterator it = begin(); it != end(); ++it ) { static_cast(*it)(arg); @@ -114,6 +121,8 @@ class Signal2: public SignalHolder { public: typedef Slot2 SlotType; + virtual ~Signal2() { } + void emit(Arg1 arg1, Arg2 arg2) { for ( Iterator it = begin(); it != end(); ++it ) { static_cast(*it)(arg1, arg2); @@ -131,6 +140,8 @@ class Signal3: public SignalHolder { public: typedef Slot3 SlotType; + virtual ~Signal3() { } + void emit(Arg1 arg1, Arg2 arg2, Arg3 arg3) { for ( Iterator it = begin(); it != end(); ++it ) { static_cast(*it)(arg1, arg2, arg3); @@ -180,16 +191,15 @@ public: class SignalTracker { public: /// Internal type, do not use. - typedef std::list< std::pair< SigImpl::SignalHolder*, SigImpl::SignalHolder::SlotID > > Connections; + typedef std::map Connections; typedef Connections::iterator TrackID; ///< \c ID type for join/leave. - ~SignalTracker() { + virtual ~SignalTracker() { // disconnect all connections for ( Connections::iterator conIt = m_connections.begin(); - conIt != m_connections.end(); ) { + conIt != m_connections.end(); ++conIt) conIt->first->disconnect( conIt->second ); - conIt = m_connections.erase( conIt ); - } + m_connections.clear(); } /// Starts tracking a signal. @@ -207,6 +217,13 @@ public: m_connections.erase(id); } + /// Leave tracking for a signal + /// @param sig the signal to leave + template + void leave(Signal &sig) { + m_connections.erase(&sig); + } + private: /// holds all connections to different signals and slots. Connections m_connections; diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 4a7c68d..fa68d00 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -429,6 +429,9 @@ Fluxbox::~Fluxbox() { // 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