Free TaxTable and BillTerms on book close

This commit is contained in:
Robert Fewell 2021-07-13 15:05:59 +01:00
parent 5ced0d932a
commit c2a6f1e911
2 changed files with 27 additions and 0 deletions

View File

@ -838,14 +838,28 @@ static void _gncBillTermCreate (QofBook *book)
qof_book_set_data (book, _GNC_MOD_NAME, bi); 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) static void _gncBillTermDestroy (QofBook *book)
{ {
struct _book_info *bi; struct _book_info *bi;
QofCollection *col;
if (!book) return; if (!book) return;
bi = qof_book_get_data (book, _GNC_MOD_NAME); 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_list_free (bi->terms);
g_free (bi); g_free (bi);
} }

View File

@ -1015,14 +1015,27 @@ static void _gncTaxTableCreate (QofBook *book)
qof_book_set_data (book, _GNC_MOD_NAME, bi); 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) static void _gncTaxTableDestroy (QofBook *book)
{ {
struct _book_info *bi; struct _book_info *bi;
QofCollection *col;
if (!book) return; if (!book) return;
bi = qof_book_get_data (book, _GNC_MOD_NAME); 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_list_free (bi->tables);
g_free (bi); g_free (bi);
} }