static void gncTaxTableFree (GncTaxTable *table) { GList *list; GncTaxTable *child; if (!table) return; qof_event_gen (&table->inst, QOF_EVENT_DESTROY, NULL); CACHE_REMOVE (table->name); remObj (table); /* destroy the list of entries */ for (list = table->entries; list; list = list->next) gncTaxTableEntryDestroy (list->data); g_list_free (table->entries); if (!qof_instance_get_destroying(table)) PERR("free a taxtable without do_free set!"); /* disconnect from parent */ if (table->parent) gncTaxTableRemoveChild(table->parent, table); /* disconnect from the children */ for (list = table->children; list; list = list->next) { child = list->data; gncTaxTableSetParent(child, NULL); } g_list_free(table->children); /* qof_instance_release (&table->inst); */ g_object_unref (table); }
GncTaxTable *gncTaxTableReturnChild (GncTaxTable *table, gboolean make_new) { GncTaxTable *child = NULL; if (!table) return NULL; if (table->child) return table->child; if (table->parent || table->invisible) return table; if (make_new) { child = gncTaxTableCopy (table); gncTaxTableSetChild (table, child); gncTaxTableSetParent (child, table); } return child; }
static void tt_set_parent( gpointer data, gpointer value ) { GncTaxTable* tt; GncTaxTable* parent; QofBook* pBook; GncGUID* guid = (GncGUID*)value; g_return_if_fail( data != NULL ); g_return_if_fail( GNC_IS_TAXTABLE(data) ); tt = GNC_TAXTABLE(data); pBook = qof_instance_get_book( QOF_INSTANCE(tt) ); if ( guid != NULL ) { parent = gncTaxTableLookup( pBook, guid ); if ( parent != NULL ) { gncTaxTableSetParent( tt, parent ); gncTaxTableSetChild( parent, tt ); } } }