From 15491e23e7e1183faabb281f207ba64f16ed088f Mon Sep 17 00:00:00 2001 From: Phil Longstaff Date: Sun, 13 Dec 2009 00:42:12 +0000 Subject: [PATCH] Free budgets when closing a book git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18491 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/gnc-budget.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/engine/gnc-budget.c b/src/engine/gnc-budget.c index ce110c4cc5..98b9801529 100644 --- a/src/engine/gnc-budget.c +++ b/src/engine/gnc-budget.c @@ -602,6 +602,21 @@ gnc_budget_get_default (QofBook *book) return bgt; } +/* Book handling routines */ + +/** + * Delete all budgets + * + * @param book Book + */ +static void +budget_book_end(QofBook* book) +{ + QofCollection *col; + col = qof_book_get_collection(book, GNC_ID_BUDGET); + qof_collection_foreach(col, (QofInstanceForeachCB)gnc_budget_destroy, NULL); +} + /* Define the QofObject. */ static QofObject budget_object_def = { @@ -610,7 +625,7 @@ static QofObject budget_object_def = .type_label = "Budget", .create = (gpointer)gnc_budget_new, .book_begin = NULL, - .book_end = NULL, + .book_end = budget_book_end, .is_dirty = qof_collection_is_dirty, .mark_clean = qof_collection_mark_clean, .foreach = qof_collection_foreach,