mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Fix memory leaks getting commodity namespaces and commodity lists.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3086 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
c50f8c1ef5
commit
9734f361ed
@ -292,20 +292,22 @@ gnc_commodity_table_find_full(const gnc_commodity_table * table,
|
|||||||
GList * all;
|
GList * all;
|
||||||
GList * iterator;
|
GList * iterator;
|
||||||
|
|
||||||
all = gnc_commodity_table_get_commodities(table, namespace);
|
if (!fullname || (fullname[0] == '\0'))
|
||||||
if(fullname && fullname[0]) {
|
|
||||||
for(iterator = all; iterator; iterator=iterator->next) {
|
|
||||||
if(!strcmp(fullname,
|
|
||||||
gnc_commodity_get_printname(iterator->data))) {
|
|
||||||
retval = iterator->data;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
all = gnc_commodity_table_get_commodities(table, namespace);
|
||||||
|
|
||||||
|
for(iterator = all; iterator; iterator=iterator->next) {
|
||||||
|
if(!strcmp(fullname,
|
||||||
|
gnc_commodity_get_printname(iterator->data))) {
|
||||||
|
retval = iterator->data;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_list_free (all);
|
||||||
|
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -266,29 +266,46 @@ xml_add_commodity_restorer(xmlNodePtr p, gnc_commodity *c) {
|
|||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
xml_add_commodity_restorers(xmlNodePtr p) {
|
xml_add_commodity_restorers(xmlNodePtr p) {
|
||||||
GList *lp;
|
|
||||||
gnc_commodity_table *commodities;
|
gnc_commodity_table *commodities;
|
||||||
|
GList *namespaces;
|
||||||
|
GList *lp;
|
||||||
|
|
||||||
if(!p) return(FALSE);
|
if(!p) return(FALSE);
|
||||||
|
|
||||||
commodities = gnc_engine_commodities();
|
commodities = gnc_engine_commodities();
|
||||||
if(!commodities) return(FALSE);
|
if(!commodities) return(FALSE);
|
||||||
|
|
||||||
for(lp = gnc_commodity_table_get_namespaces(commodities); lp; lp = lp->next) {
|
namespaces = gnc_commodity_table_get_namespaces(commodities);
|
||||||
|
|
||||||
|
for(lp = namespaces; lp; lp = lp->next) {
|
||||||
gchar *space;
|
gchar *space;
|
||||||
if(!lp->data) return(FALSE);
|
|
||||||
if(!lp->data) return(FALSE);
|
if(!lp->data) {
|
||||||
|
g_list_free (namespaces);
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
space = (gchar *) lp->data;
|
space = (gchar *) lp->data;
|
||||||
if(strcmp(GNC_COMMODITY_NS_ISO, space) != 0) {
|
if(strcmp(GNC_COMMODITY_NS_ISO, space) != 0) {
|
||||||
GList *comms = gnc_commodity_table_get_commodities(commodities, space);
|
GList *comms = gnc_commodity_table_get_commodities(commodities, space);
|
||||||
GList *lp2;
|
GList *lp2;
|
||||||
|
|
||||||
for(lp2 = comms; lp2; lp2 = lp2->next) {
|
for(lp2 = comms; lp2; lp2 = lp2->next) {
|
||||||
gnc_commodity *com = (gnc_commodity *) lp2->data;
|
gnc_commodity *com = (gnc_commodity *) lp2->data;
|
||||||
if(!xml_add_commodity_restorer(p, com)) return(FALSE);
|
|
||||||
|
if(!xml_add_commodity_restorer(p, com)) {
|
||||||
|
g_list_free (comms);
|
||||||
|
g_list_free (namespaces);
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_list_free (comms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_list_free (namespaces);
|
||||||
|
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ gnc_ui_update_namespace_picker(GtkWidget * combobox,
|
|||||||
const char * init_string) {
|
const char * init_string) {
|
||||||
GList * namespaces;
|
GList * namespaces;
|
||||||
char * active;
|
char * active;
|
||||||
|
|
||||||
/* fetch a list of the namespaces */
|
/* fetch a list of the namespaces */
|
||||||
namespaces = gnc_commodity_table_get_namespaces(gnc_engine_commodities());
|
namespaces = gnc_commodity_table_get_namespaces(gnc_engine_commodities());
|
||||||
namespaces = g_list_sort(namespaces, g_strcmp);
|
namespaces = g_list_sort(namespaces, g_strcmp);
|
||||||
|
@ -308,7 +308,7 @@ gnc_option_set_ui_value(GNCOption *option, gboolean use_default)
|
|||||||
{
|
{
|
||||||
GList *list;
|
GList *list;
|
||||||
|
|
||||||
list = gnc_scm_to_account_list(value);
|
list = gnc_scm_to_glist_account_ptr(value);
|
||||||
|
|
||||||
gtk_clist_unselect_all(GTK_CLIST(option->widget));
|
gtk_clist_unselect_all(GTK_CLIST(option->widget));
|
||||||
gnc_account_tree_select_accounts(GNC_ACCOUNT_TREE(option->widget),
|
gnc_account_tree_select_accounts(GNC_ACCOUNT_TREE(option->widget),
|
||||||
@ -530,9 +530,8 @@ gnc_option_get_ui_value(GNCOption *option)
|
|||||||
tree = GNC_ACCOUNT_TREE(option->widget);
|
tree = GNC_ACCOUNT_TREE(option->widget);
|
||||||
list = gnc_account_tree_get_current_accounts(tree);
|
list = gnc_account_tree_get_current_accounts(tree);
|
||||||
|
|
||||||
result = gnc_account_list_to_scm(list);
|
/* handover list */
|
||||||
|
result = gnc_glist_account_ptr_to_scm(list);
|
||||||
g_list_free(list);
|
|
||||||
}
|
}
|
||||||
else if (safe_strcmp(type, "list") == 0)
|
else if (safe_strcmp(type, "list") == 0)
|
||||||
{
|
{
|
||||||
|
@ -162,7 +162,11 @@ gnc_ui_commodity_druid_create(const char * filename) {
|
|||||||
GNOME_DRUID_PAGE(new_page->page));
|
GNOME_DRUID_PAGE(new_page->page));
|
||||||
back_page = GNOME_DRUID_PAGE(new_page->page);
|
back_page = GNOME_DRUID_PAGE(new_page->page);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_widget_show_all(d->window);
|
gtk_widget_show_all(d->window);
|
||||||
|
|
||||||
|
g_list_free(orphans);
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user