Fix memory allocation bug

This commit is contained in:
Markus Koch 2019-07-24 21:25:53 +02:00
parent 6985002bdc
commit f5607875e5

View File

@ -26,9 +26,9 @@ struct mainWindow *mainWindow_new(GtkApplication *app)
void mainWindow_scan_tags(YacosScanner *scanner, struct mainWindow *mainWindow) void mainWindow_scan_tags(YacosScanner *scanner, struct mainWindow *mainWindow)
{ {
// TODO: For testing only // TODO: Currently slow AF! And dirty. Pls rewrite (yea yea I know you won't...)
gtk_stack_set_visible_child(mainWindow->stack_main, mainWindow->page_cart.box); gtk_stack_set_visible_child(mainWindow->stack_main, mainWindow->page_cart.box);
GtkWidget *le = yacos_cart_item_new(); GtkWidget *le;
GList *l; GList *l;
yacos_tag_id tag_id; yacos_tag_id tag_id;
@ -38,7 +38,7 @@ void mainWindow_scan_tags(YacosScanner *scanner, struct mainWindow *mainWindow)
for (l = yacos_scanner_get_present_tags(scanner); l != NULL; l = l->next) { for (l = yacos_scanner_get_present_tags(scanner); l != NULL; l = l->next) {
tag_id = ((struct yacos_scanner_tag*) l->data)->tag_id; tag_id = ((struct yacos_scanner_tag*) l->data)->tag_id;
stack_children = gtk_container_get_children(mainWindow->page_cart.list); stack_children = gtk_container_get_children(GTK_CONTAINER(mainWindow->page_cart.list));
for (ll = stack_children; ll != NULL; ll = ll->next) { for (ll = stack_children; ll != NULL; ll = ll->next) {
if (yacos_cart_item_get_id(((YacosCartItem *) ll->data)) == tag_id) { if (yacos_cart_item_get_id(((YacosCartItem *) ll->data)) == tag_id) {
found = 1; found = 1;
@ -47,6 +47,7 @@ void mainWindow_scan_tags(YacosScanner *scanner, struct mainWindow *mainWindow)
} }
if (found) if (found)
continue; continue;
le = yacos_cart_item_new();
yacos_cart_item_set_id(YACOS_CART_ITEM(le), tag_id); yacos_cart_item_set_id(YACOS_CART_ITEM(le), tag_id);
yacos_cart_item_fetch_meta(YACOS_CART_ITEM(le)); yacos_cart_item_fetch_meta(YACOS_CART_ITEM(le));
yacos_cart_item_fetch_image(YACOS_CART_ITEM(le)); yacos_cart_item_fetch_image(YACOS_CART_ITEM(le));