From e54bca68d2bd42f9b9c342a1564971db6e071808 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Mon, 8 Aug 2011 13:31:25 +0200 Subject: Make sure FocusableList disconnects from signals when it is destroyed --- src/FocusableList.cc | 13 +++++-------- src/FocusableList.hh | 13 ++++++------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/FocusableList.cc b/src/FocusableList.cc index 3373890..382a6f5 100644 --- a/src/FocusableList.cc +++ b/src/FocusableList.cc @@ -94,7 +94,11 @@ FocusableList::FocusableList(BScreen &scr, const FocusableList &parent, void FocusableList::init() { addMatching(); - m_parent->attachChild(*this); + + join(m_parent->addSig(), FbTk::MemFun(*this, &FocusableList::parentWindowAdded)); + join(m_parent->orderSig(), FbTk::MemFun(*this, &FocusableList::parentOrderChanged)); + join(m_parent->removeSig(), FbTk::MemFun(*this, &FocusableList::parentWindowRemoved)); + join(m_parent->resetSig(), FbTk::MemFun(*this, &FocusableList::reset)); // TODO: can't handle (head=[mouse]) yet if (m_pat->dependsOnCurrentWorkspace()) { @@ -291,13 +295,6 @@ Focusable *FocusableList::find(const ClientPattern &pat) const { return 0; } -void FocusableList::attachChild(FocusableList &child) const { - m_addsig.connect(FbTk::MemFun(child, &FocusableList::parentWindowAdded)); - m_ordersig.connect(FbTk::MemFun(child, &FocusableList::parentOrderChanged)); - m_removesig.connect(FbTk::MemFun(child, &FocusableList::parentWindowRemoved)); - m_resetsig.connect(FbTk::MemFun(child, &FocusableList::reset)); -} - void FocusableList::workspaceChanged(BScreen &screen) { reset(); } diff --git a/src/FocusableList.hh b/src/FocusableList.hh index 48881d0..a56fdbd 100644 --- a/src/FocusableList.hh +++ b/src/FocusableList.hh @@ -78,10 +78,10 @@ public: @name signals @{ */ - FbTk::Signal &orderSig() { return m_ordersig; } - FbTk::Signal &addSig() { return m_addsig; } - FbTk::Signal &removeSig() { return m_removesig; } - FbTk::Signal<> &resetSig() { return m_resetsig; } + const FbTk::Signal &orderSig() const { return m_ordersig; } + const FbTk::Signal &addSig() const { return m_addsig; } + const FbTk::Signal &removeSig() const { return m_removesig; } + const FbTk::Signal<> &resetSig() const { return m_resetsig; } /** @} */ // end group signals private: @@ -91,7 +91,6 @@ private: bool insertFromParent(Focusable &win); void attachSignals(Focusable &win); void reset(); - void attachChild(FocusableList &child) const; void workspaceChanged(BScreen &screen); void focusedWindowChanged(BScreen &screen, FluxboxWindow *win, WinClient *client); /// Title has changed for a window @@ -108,8 +107,8 @@ private: BScreen &m_screen; std::list m_list; - mutable FbTk::Signal m_ordersig, m_addsig, m_removesig; - mutable FbTk::Signal<> m_resetsig; + FbTk::Signal m_ordersig, m_addsig, m_removesig; + FbTk::Signal<> m_resetsig; typedef std::map > SignalMap; SignalMap m_signal_map; }; -- cgit v0.11.2