aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-08-09 22:58:36 +0200
committerfiaxh <git@mx.ax.lt>2017-08-11 11:56:41 +0200
commitdd88db7556a20707f6fe3c81b3c58df42a0f5224 (patch)
tree6c32a9bc7783c3cdf7a6b2814555607307085439 /main/src/ui
parentb29d52fddae832d275e66dbd1b494e06ce11d0da (diff)
downloaddino-dd88db7556a20707f6fe3c81b3c58df42a0f5224.tar.gz
dino-dd88db7556a20707f6fe3c81b3c58df42a0f5224.zip
RosterList: Disconnect handlers on widget destroy
Fixes #119
Diffstat (limited to 'main/src/ui')
-rw-r--r--main/src/ui/add_conversation/chat/roster_list.vala16
1 files changed, 11 insertions, 5 deletions
diff --git a/main/src/ui/add_conversation/chat/roster_list.vala b/main/src/ui/add_conversation/chat/roster_list.vala
index 3c324cf6..f4b42cc4 100644
--- a/main/src/ui/add_conversation/chat/roster_list.vala
+++ b/main/src/ui/add_conversation/chat/roster_list.vala
@@ -11,6 +11,7 @@ protected class RosterList : FilterableList {
public signal void conversation_selected(Conversation? conversation);
private StreamInteractor stream_interactor;
private Gee.List<Account> accounts;
+ private ulong[] handler_ids = new ulong[0];
private HashMap<Account, HashMap<Jid, ListRow>> rows = new HashMap<Account, HashMap<Jid, ListRow>>(Account.hash_func, Account.equals_func);
@@ -22,13 +23,18 @@ protected class RosterList : FilterableList {
set_header_func(header);
set_sort_func(sort);
- stream_interactor.get_module(RosterManager.IDENTITY).removed_roster_item.connect( (account, jid, roster_item) => {
- if (accounts.contains(account))
+ handler_ids += stream_interactor.get_module(RosterManager.IDENTITY).removed_roster_item.connect( (account, jid, roster_item) => {
+ if (accounts.contains(account)) {
Idle.add(() => { on_removed_roster_item(account, jid, roster_item); return false;});
+ }
});
- stream_interactor.get_module(RosterManager.IDENTITY).updated_roster_item.connect( (account, jid, roster_item) => {
- if (accounts.contains(account))
+ handler_ids += stream_interactor.get_module(RosterManager.IDENTITY).updated_roster_item.connect( (account, jid, roster_item) => {
+ if (accounts.contains(account)) {
Idle.add(() => { on_updated_roster_item(account, jid, roster_item); return false;});
+ }
+ });
+ destroy.connect(() => {
+ foreach (ulong handler_id in handler_ids) stream_interactor.get_module(RosterManager.IDENTITY).disconnect(handler_id);
});
foreach (Account a in accounts) fetch_roster_items(a);
@@ -85,4 +91,4 @@ protected class RosterList : FilterableList {
}
}
-} \ No newline at end of file
+}