diff --git a/libgnucash/engine/gncBillTerm.c b/libgnucash/engine/gncBillTerm.c index fb6f2bb15c..844a2e398b 100644 --- a/libgnucash/engine/gncBillTerm.c +++ b/libgnucash/engine/gncBillTerm.c @@ -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); } diff --git a/libgnucash/engine/gncTaxTable.c b/libgnucash/engine/gncTaxTable.c index 3cd689db5c..23f195a648 100644 --- a/libgnucash/engine/gncTaxTable.c +++ b/libgnucash/engine/gncTaxTable.c @@ -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); }