mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-25 10:20:18 -06:00
[test] Fix memory leak in test-gnc-quotes
When the commodity table is registered, the current book will get a default table assigned. When later setting the table explicitly using qof_book_set_data() the exisiting table gets overwritten and is thus leaked. There is no way of removing or freeing a currency table from a book, so the best we can do here is to set our own table on the book before calling gnc_commodity_table_register().
This commit is contained in:
parent
6be682b645
commit
71802b5627
@ -90,10 +90,15 @@ protected:
|
||||
m_book{qof_session_get_book(gnc_get_current_session())}
|
||||
{
|
||||
qof_init();
|
||||
gnc_commodity_table_register();
|
||||
gnc_pricedb_register();
|
||||
|
||||
/* By setting an empty commodity table on the book before registering
|
||||
* the commodity_table type we avoid adding the default commodities */
|
||||
auto comm_table{gnc_commodity_table_new()};
|
||||
qof_book_set_data(m_book, GNC_COMMODITY_TABLE, comm_table);
|
||||
|
||||
gnc_commodity_table_register();
|
||||
gnc_pricedb_register();
|
||||
|
||||
auto eur = gnc_commodity_new(m_book, "Euro", "ISO4217", "EUR", NULL, 100);
|
||||
auto source{gnc_quote_source_lookup_by_internal("currency")};
|
||||
gnc_commodity_begin_edit(eur);
|
||||
|
Loading…
Reference in New Issue
Block a user