| 539 | | if (builder->schema->use_lang == 1) { |
|---|
| 540 | | |
|---|
| 541 | | gchar *guid = NULL; |
|---|
| 542 | | GList *nlist = NULL; |
|---|
| 543 | | |
|---|
| 544 | | if((midgard_lang_get(builder->mgd) != 0) |
|---|
| 545 | | && builder->lang == -1) |
|---|
| 546 | | list = g_list_reverse(list); |
|---|
| 547 | | |
|---|
| 548 | | for(; list ; list = list->next){ |
|---|
| 549 | | |
|---|
| 550 | | /* Bit of hack, records could be returned with lang DESC */ |
|---|
| 551 | | |
|---|
| 552 | | if(select_type == MQB_SELECT_OBJECT) { |
|---|
| 553 | | g_object_get(G_OBJECT(list->data), "guid", &guid, NULL); |
|---|
| 554 | | } else if (select_type == MQB_SELECT_GUID) { |
|---|
| 555 | | guid = g_strdup((gchar *)list->data); |
|---|
| 556 | | } |
|---|
| 557 | | /* Changed to find_custom due to bug in GLib docs */ |
|---|
| 558 | | /* g_list_find never returns NULL */ |
|---|
| 559 | | /* We could use g_hash_table as well */ |
|---|
| 560 | | if((tmp_list = g_list_find_custom(tmp_list, |
|---|
| 561 | | guid, _compare_ml_guid))) { |
|---|
| 562 | | |
|---|
| 563 | | g_free((gchar *)tmp_list->data); |
|---|
| 564 | | tmp_list->data = g_strdup(""); /* FIXME */ |
|---|
| 565 | | |
|---|
| 566 | | if(select_type == MQB_SELECT_OBJECT) { |
|---|
| 567 | | g_object_unref(G_OBJECT(list->data)); |
|---|
| 568 | | } else if (select_type == MQB_SELECT_GUID) { |
|---|
| 569 | | /* TODO check leak, none for now */ |
|---|
| 570 | | /* g_free(list->data); */ |
|---|
| 571 | | } |
|---|
| 572 | | |
|---|
| 573 | | } else { |
|---|
| 574 | | nlist = g_list_append(nlist, list->data); |
|---|
| 575 | | } |
|---|
| 576 | | tmp_list = g_list_prepend(tmp_list, (gpointer)guid); |
|---|
| 577 | | } |
|---|
| 578 | | |
|---|
| 579 | | /* Free unused guids */ |
|---|
| 580 | | for(; tmp_list ; tmp_list = tmp_list->next){ |
|---|
| 581 | | g_free((gchar *)tmp_list->data); |
|---|
| 582 | | } |
|---|
| 583 | | g_list_free(tmp_list); |
|---|
| 584 | | g_list_free(list); |
|---|
| 585 | | list = nlist; |
|---|
| 586 | | } |
|---|
| 587 | | |
|---|