Skip to content

Commit

Permalink
Free TaxTable and BillTerms on book close
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob-IT committed Aug 12, 2021
1 parent 5ced0d9 commit c2a6f1e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions libgnucash/engine/gncBillTerm.c
Expand Up @@ -838,14 +838,28 @@ static void _gncBillTermCreate (QofBook *book)
qof_book_set_data (book, _GNC_MOD_NAME, bi);
}


static void
destroy_billterm_on_book_close (QofInstance *ent, gpointer data)
{
GncBillTerm *term = GNC_BILLTERM(ent);

gncBillTermBeginEdit (term);
gncBillTermDestroy (term);
}

static void _gncBillTermDestroy (QofBook *book)
{
struct _book_info *bi;
QofCollection *col;

if (!book) return;

bi = qof_book_get_data (book, _GNC_MOD_NAME);

col = qof_book_get_collection (book, GNC_ID_BILLTERM);
qof_collection_foreach (col, destroy_billterm_on_book_close, NULL);

g_list_free (bi->terms);
g_free (bi);
}
Expand Down
13 changes: 13 additions & 0 deletions libgnucash/engine/gncTaxTable.c
Expand Up @@ -1015,14 +1015,27 @@ static void _gncTaxTableCreate (QofBook *book)
qof_book_set_data (book, _GNC_MOD_NAME, bi);
}

static void
destroy_taxtable_on_book_close (QofInstance *ent, gpointer data)
{
GncTaxTable *table = GNC_TAXTABLE(ent);

gncTaxTableBeginEdit (table);
gncTaxTableDestroy (table);
}

static void _gncTaxTableDestroy (QofBook *book)
{
struct _book_info *bi;
QofCollection *col;

if (!book) return;

bi = qof_book_get_data (book, _GNC_MOD_NAME);

col = qof_book_get_collection (book, GNC_ID_TAXTABLE);
qof_collection_foreach (col, destroy_taxtable_on_book_close, NULL);

g_list_free (bi->tables);
g_free (bi);
}
Expand Down

0 comments on commit c2a6f1e

Please sign in to comment.