Fix crash when removing jid from roster

fixes #1332
This commit is contained in:
fiaxh 2023-01-11 19:49:27 +01:00
parent 75500dc767
commit 860c72bfc9
2 changed files with 6 additions and 5 deletions

View File

@ -14,7 +14,7 @@ protected class RosterList {
private ulong[] handler_ids = new ulong[0];
private ListBox list_box = new ListBox();
private HashMap<Account, HashMap<Jid, ListRow>> rows = new HashMap<Account, HashMap<Jid, ListRow>>(Account.hash_func, Account.equals_func);
private HashMap<Account, HashMap<Jid, ListBoxRow>> rows = new HashMap<Account, HashMap<Jid, ListBoxRow>>(Account.hash_func, Account.equals_func);
public RosterList(StreamInteractor stream_interactor, Gee.List<Account> accounts) {
this.stream_interactor = stream_interactor;
@ -47,14 +47,15 @@ protected class RosterList {
private void on_updated_roster_item(Account account, Jid jid, Roster.Item roster_item) {
on_removed_roster_item(account, jid, roster_item);
ListRow row = new ListRow.from_jid(stream_interactor, roster_item.jid, account, accounts.size > 1);
rows[account][jid] = row;
list_box.append(row);
ListBoxRow list_box_row = new ListBoxRow() { child=row };
rows[account][jid] = list_box_row;
list_box.append(list_box_row);
list_box.invalidate_sort();
list_box.invalidate_filter();
}
private void fetch_roster_items(Account account) {
rows[account] = new HashMap<Jid, ListRow>(Jid.hash_func, Jid.equals_func);
rows[account] = new HashMap<Jid, ListBoxRow>(Jid.hash_func, Jid.equals_func);
foreach (Roster.Item roster_item in stream_interactor.get_module(RosterManager.IDENTITY).get_roster(account)) {
on_updated_roster_item(account, roster_item.jid, roster_item);
}

View File

@ -80,7 +80,7 @@ public class SelectContactDialog : Gtk.Dialog {
add_contact_dialog.present();
});
select_jid_fragment.remove_jid.connect((row) => {
ListRow list_row = roster_list_box.get_selected_row() as ListRow;
ListRow list_row = roster_list_box.get_selected_row().child as ListRow;
stream_interactor.get_module(RosterManager.IDENTITY).remove_jid(list_row.account, list_row.jid);
});
select_jid_fragment.notify["done"].connect(() => {