Wrap BillTermDecRef and TaxTableDecRef in test for shutdown

When Gnucash is shutting down, the TaxTables and BillTerms will be
destroyed/freed and may already have been so there is no point trying
to decrement a reference that is used to stop them being destroyed if
in use.
This commit is contained in:
Robert Fewell 2021-08-14 11:01:38 +01:00
parent b421b3d2af
commit 6a9ff287cd
4 changed files with 27 additions and 15 deletions

View File

@ -358,11 +358,12 @@ static void gncCustomerFree (GncCustomer *cust)
g_list_free (cust->jobs);
g_free (cust->balance);
if (cust->terms)
gncBillTermDecRef (cust->terms);
if (cust->taxtable)
if (!qof_book_shutting_down (qof_instance_get_book (QOF_INSTANCE(cust))))
{
gncTaxTableDecRef (cust->taxtable);
if (cust->terms)
gncBillTermDecRef (cust->terms);
if (cust->taxtable)
gncTaxTableDecRef (cust->taxtable);
}
/* qof_instance_release (&cust->inst); */

View File

@ -462,10 +462,14 @@ static void gncEntryFree (GncEntry *entry)
gncAccountValueDestroy (entry->i_tax_values);
if (entry->b_tax_values)
gncAccountValueDestroy (entry->b_tax_values);
if (entry->i_tax_table)
gncTaxTableDecRef (entry->i_tax_table);
if (entry->b_tax_table)
gncTaxTableDecRef (entry->b_tax_table);
if (!qof_book_shutting_down (qof_instance_get_book (QOF_INSTANCE(entry))))
{
if (entry->i_tax_table)
gncTaxTableDecRef (entry->i_tax_table);
if (entry->b_tax_table)
gncTaxTableDecRef (entry->b_tax_table);
}
/* qof_instance_release (&entry->inst); */
g_object_unref (entry);

View File

@ -423,10 +423,14 @@ static void gncInvoiceFree (GncInvoice *invoice)
g_list_free (invoice->entries);
g_list_free (invoice->prices);
if (invoice->printname) g_free (invoice->printname);
if (invoice->printname)
g_free (invoice->printname);
if (invoice->terms)
gncBillTermDecRef (invoice->terms);
if (!qof_book_shutting_down (qof_instance_get_book (QOF_INSTANCE(invoice))))
{
if (invoice->terms)
gncBillTermDecRef (invoice->terms);
}
/* qof_instance_release (&invoice->inst); */
g_object_unref (invoice);

View File

@ -501,10 +501,13 @@ static void gncVendorFree (GncVendor *vendor)
g_list_free (vendor->jobs);
g_free (vendor->balance);
if (vendor->terms)
gncBillTermDecRef (vendor->terms);
if (vendor->taxtable)
gncTaxTableDecRef (vendor->taxtable);
if (!qof_book_shutting_down (qof_instance_get_book (QOF_INSTANCE(vendor))))
{
if (vendor->terms)
gncBillTermDecRef (vendor->terms);
if (vendor->taxtable)
gncTaxTableDecRef (vendor->taxtable);
}
/* qof_instance_release (&vendor->inst); */
g_object_unref (vendor);