From 9e207abee322918b07356edbf0ec7fc5e7e5a0e5 Mon Sep 17 00:00:00 2001 From: velsinki <112010-velsinki@users.noreply.gitlab.gnome.org> Date: Tue, 14 Nov 2023 00:18:50 +0100 Subject: [PATCH] applications: Fix File & Link Associations crash The selection of rows in the applications listbox is unreliable and currently even disabled. This means that for File & Link Associations, the unset and reset handlers crash because they try to retrieve the currently selected row of the listbox, and dereference it. Instead, we can use the current info that is always stored in self anyways. Fixes #2752 --- panels/applications/cc-applications-panel.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/panels/applications/cc-applications-panel.c b/panels/applications/cc-applications-panel.c index fc5f0bf6e..5f29ca9f2 100644 --- a/panels/applications/cc-applications-panel.c +++ b/panels/applications/cc-applications-panel.c @@ -973,15 +973,10 @@ unset_cb (CcApplicationsPanel *self, GtkButton *button) { const gchar *type; - GtkListBoxRow *selected; - GAppInfo *info; - - selected = gtk_list_box_get_selected_row (self->app_listbox); - info = cc_applications_row_get_info (CC_APPLICATIONS_ROW (selected)); type = (const gchar *)g_object_get_data (G_OBJECT (button), "type"); - g_app_info_remove_supports_type (info, type, NULL); + g_app_info_remove_supports_type (self->current_app_info, type, NULL); } static void @@ -1086,15 +1081,10 @@ app_info_recommended_for (GAppInfo *info, static void handler_reset_cb (CcApplicationsPanel *self) { - GtkListBoxRow *selected; - GAppInfo *info; const gchar **types; gint i; - selected = gtk_list_box_get_selected_row (self->app_listbox); - info = cc_applications_row_get_info (CC_APPLICATIONS_ROW (selected)); - - types = g_app_info_get_supported_types (info); + types = g_app_info_get_supported_types (self->current_app_info); if (types == NULL || types[0] == NULL) return; @@ -1102,7 +1092,7 @@ handler_reset_cb (CcApplicationsPanel *self) for (i = 0; types[i]; i++) { gchar *ctype = g_content_type_from_mime_type (types[i]); - g_app_info_add_supports_type (info, ctype, NULL); + g_app_info_add_supports_type (self->current_app_info, ctype, NULL); } g_signal_handler_unblock (self->monitor, self->monitor_id); g_signal_emit_by_name (self->monitor, "changed");