Remove duplicates.

This commit is contained in:
Jari Vetoniemi 2014-10-25 21:54:14 +03:00
parent ba03036a39
commit 2294ff46e5

View File

@ -121,6 +121,15 @@ read_items_to_menu_from_dir(struct bm_menu *menu, const char *path)
uint32_t count;
struct bm_item **items = bm_menu_get_items(menu, &count);
qsort(items, count, sizeof(struct bm_item*), compare);
bool unique = true;
for (uint32_t i = 0; i + 1 < count; i += unique) {
if (!(unique = strcmp(bm_item_get_text(items[i]), bm_item_get_text(items[i + 1])))) {
bm_item_free(items[i]);
bm_menu_remove_item_at(menu, i);
items = bm_menu_get_items(menu, &count);
}
}
}
static void