Make sure FocusableList disconnects from signals when it is destroyed

This commit is contained in:
Pavel Labath 2011-08-08 13:31:25 +02:00
parent aa84c95253
commit e54bca68d2
2 changed files with 11 additions and 15 deletions

View file

@ -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();
}

View file

@ -78,10 +78,10 @@ public:
@name signals
@{
*/
FbTk::Signal<Focusable *> &orderSig() { return m_ordersig; }
FbTk::Signal<Focusable *> &addSig() { return m_addsig; }
FbTk::Signal<Focusable *> &removeSig() { return m_removesig; }
FbTk::Signal<> &resetSig() { return m_resetsig; }
const FbTk::Signal<Focusable *> &orderSig() const { return m_ordersig; }
const FbTk::Signal<Focusable *> &addSig() const { return m_addsig; }
const FbTk::Signal<Focusable *> &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<Focusable *> m_list;
mutable FbTk::Signal<Focusable *> m_ordersig, m_addsig, m_removesig;
mutable FbTk::Signal<> m_resetsig;
FbTk::Signal<Focusable *> m_ordersig, m_addsig, m_removesig;
FbTk::Signal<> m_resetsig;
typedef std::map<Focusable*, FbTk::RefCount<FbTk::SignalTracker> > SignalMap;
SignalMap m_signal_map;
};