]> Dogcows Code - chaz/openbox/commitdiff
make the client list menu update properly and not crash
authorDana Jansens <danakj@orodu.net>
Wed, 23 May 2007 04:08:16 +0000 (04:08 +0000)
committerDana Jansens <danakj@orodu.net>
Wed, 23 May 2007 04:08:16 +0000 (04:08 +0000)
openbox/client_list_menu.c

index 77cfc1933121a0e31ce744a3434cc09274b715d4..e5ad17a394367b293b1c3b3b20bad26689cccf21 100644 (file)
@@ -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 */
This page took 0.024489 seconds and 4 git commands to generate.