From: Dana Jansens Date: Wed, 23 May 2007 04:08:16 +0000 (+0000) Subject: make the client list menu update properly and not crash X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=e9115802d51795646d9c19015d77d74380e471a7;p=chaz%2Fopenbox make the client list menu update properly and not crash --- diff --git a/openbox/client_list_menu.c b/openbox/client_list_menu.c index 77cfc193..e5ad17a3 100644 --- a/openbox/client_list_menu.c +++ b/openbox/client_list_menu.c @@ -136,33 +136,30 @@ static gboolean self_update(ObMenuFrame *frame, gpointer data) ObMenu *menu = frame->menu; guint i; GSList *it, *next; + + menu_clear_entries(menu); + + while (desktop_menus) { + menu_free(desktop_menus->data); + desktop_menus = g_slist_delete_link(desktop_menus, desktop_menus); + } - it = desktop_menus; for (i = 0; i < screen_num_desktops; ++i) { - if (!it) { - ObMenu *submenu; - gchar *name = g_strdup_printf("%s-%u", MENU_NAME, i); - DesktopData *data = g_new(DesktopData, 1); + ObMenu *submenu; + gchar *name = g_strdup_printf("%s-%u", MENU_NAME, i); + DesktopData *data = g_new(DesktopData, 1); - data->desktop = i; - submenu = menu_new(name, screen_desktop_names[i], FALSE, data); - menu_set_update_func(submenu, desk_menu_update); - menu_set_execute_func(submenu, desk_menu_execute); - menu_set_destroy_func(submenu, desk_menu_destroy); + data->desktop = i; + submenu = menu_new(name, screen_desktop_names[i], FALSE, data); + menu_set_update_func(submenu, desk_menu_update); + menu_set_execute_func(submenu, desk_menu_execute); + menu_set_destroy_func(submenu, desk_menu_destroy); - menu_add_submenu(menu, i, name); + menu_add_submenu(menu, i, name); - g_free(name); + g_free(name); - desktop_menus = g_slist_append(desktop_menus, submenu); - } else - it = g_slist_next(it); - } - for (; it; it = next, ++i) { - next = g_slist_next(it); - menu_free(it->data); - desktop_menus = g_slist_delete_link(desktop_menus, it); - menu_entry_remove(menu_find_entry_id(menu, i)); + desktop_menus = g_slist_append(desktop_menus, submenu); } return TRUE; /* always show */