From 104581174641622c091d13651eb3675ed7c422cf Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Tue, 10 Jun 2003 04:13:56 +0000 Subject: [PATCH] fix memory management relating to starage of group in book git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@8530 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/backend/file/io-gncbin-r.c | 6 +----- src/backend/file/io-gncxml-v1.c | 24 ++++++------------------ 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/backend/file/io-gncbin-r.c b/src/backend/file/io-gncbin-r.c index 0907f0282c..cc9c25b97d 100644 --- a/src/backend/file/io-gncbin-r.c +++ b/src/backend/file/io-gncbin-r.c @@ -520,11 +520,7 @@ gnc_load_financials_from_fd(GNCBook *book, int fd) xaccLogEnable(); - { - AccountGroup *g = gnc_book_get_group(book); - gnc_book_set_group(book, grp); - if (g) xaccFreeAccountGroup(g); - } + xaccSetAccountGroup(book, grp); /* mark the newly read book as saved, since the act of putting it * together will have caused it to be marked up as not-saved. */ diff --git a/src/backend/file/io-gncxml-v1.c b/src/backend/file/io-gncxml-v1.c index b7bf8c3090..b5520ecd0b 100644 --- a/src/backend/file/io-gncxml-v1.c +++ b/src/backend/file/io-gncxml-v1.c @@ -35,6 +35,8 @@ #include "gnc-xml-helper.h" #include "Account.h" #include "AccountP.h" +#include "Group.h" +#include "GroupP.h" #include "Query.h" #include "QueryP.h" #include "Scrub.h" @@ -387,30 +389,16 @@ gnc_session_load_from_xml_file(GNCSession *session) sixtp_destroy(top_level_pr); - if(parse_ok) { - if(!global_parse_status.account_group) - return FALSE; + if(parse_ok) + { + if(!global_parse_status.account_group) return FALSE; - { - AccountGroup *g = gnc_book_get_group(book); - - gnc_book_set_group(book, global_parse_status.account_group); - - if(g) - { - xaccAccountGroupBeginEdit(g); - xaccAccountGroupDestroy(g); - } - } + xaccSetAccountGroup(book, global_parse_status.account_group); if(global_parse_status.pricedb) { gnc_pricedb_set_db(book, global_parse_status.pricedb); } - else - { - gnc_pricedb_set_db(book, gnc_pricedb_create(book)); - } /* Fix account and transaction commodities */ xaccGroupScrubCommodities (gnc_book_get_group(book));