pidgin/pidgin

Parents 3f2e9e346f6f
Children b393df36f106
Clean up the account actions lists as we're iterating to avoid having to iterate it twice.
--- a/pidgin/pidginaccountactionsmenu.c Sun Apr 26 03:22:31 2020 -0500
+++ b/pidgin/pidginaccountactionsmenu.c Thu Apr 30 20:27:38 2020 -0500
@@ -126,13 +126,13 @@
if(PURPLE_PROTOCOL_IMPLEMENTS(protocol, CLIENT, get_actions)) {
GtkWidget *item = NULL;
- GList *actions = NULL, *l = NULL;
+ GList *actions = NULL;
actions = purple_protocol_client_iface_get_actions(protocol,
connection);
- for(l = actions; l; l = l->next) {
- PurpleProtocolAction *action = (PurpleProtocolAction *)l->data;
+ while(actions != NULL) {
+ PurpleProtocolAction *action = (PurpleProtocolAction *)actions->data;
if(action == NULL) {
item = gtk_separator_menu_item_new();
@@ -160,9 +160,12 @@
/* since we added an item, make sure items_added is true */
show_separator = TRUE;
+
+ /* Iterate to the next item while deleting the one we just
+ * processed.
+ */
+ actions = g_list_remove(actions, actions->data);
}
-
- g_list_free(actions);
}
/* if we added any items, make our separator visible. */