From 860c72bfc93d252d45eb97e71cf9ff22985c7ef9 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Wed, 11 Jan 2023 19:49:27 +0100 Subject: Fix crash when removing jid from roster fixes #1332 --- main/src/ui/add_conversation/roster_list.vala | 9 +++++---- main/src/ui/add_conversation/select_contact_dialog.vala | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'main/src/ui') diff --git a/main/src/ui/add_conversation/roster_list.vala b/main/src/ui/add_conversation/roster_list.vala index 25827d67..bb338ce5 100644 --- a/main/src/ui/add_conversation/roster_list.vala +++ b/main/src/ui/add_conversation/roster_list.vala @@ -14,7 +14,7 @@ protected class RosterList { private ulong[] handler_ids = new ulong[0]; private ListBox list_box = new ListBox(); - private HashMap> rows = new HashMap>(Account.hash_func, Account.equals_func); + private HashMap> rows = new HashMap>(Account.hash_func, Account.equals_func); public RosterList(StreamInteractor stream_interactor, Gee.List 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.hash_func, Jid.equals_func); + rows[account] = new HashMap(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); } diff --git a/main/src/ui/add_conversation/select_contact_dialog.vala b/main/src/ui/add_conversation/select_contact_dialog.vala index 09ac1636..b18f4c10 100644 --- a/main/src/ui/add_conversation/select_contact_dialog.vala +++ b/main/src/ui/add_conversation/select_contact_dialog.vala @@ -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(() => { -- cgit v1.2.3-70-g09d2