static void taxtable_reset_refcount (gpointer key, gpointer value, gpointer notused) { GncTaxTable *table = key; gint32 count = GPOINTER_TO_INT(value); if (count != gncTaxTableGetRefcount(table) && !gncTaxTableGetInvisible(table)) { PWARN("Fixing refcount on taxtable %s (%" G_GINT64_FORMAT " -> %d)\n", guid_to_string(qof_instance_get_guid(QOF_INSTANCE(table))), gncTaxTableGetRefcount(table), count); gncTaxTableSetRefcount(table, count); } }
static void taxtable_reset_refcount (gpointer key, gpointer value, gpointer notused) { GncTaxTable *table = static_cast<decltype(table)>(key); gint32 count = GPOINTER_TO_INT(value); if (count != gncTaxTableGetRefcount(table) && !gncTaxTableGetInvisible(table)) { gchar guidstr[GUID_ENCODING_LENGTH+1]; guid_to_string_buff(qof_instance_get_guid(QOF_INSTANCE(table)),guidstr); PWARN("Fixing refcount on taxtable %s (%" G_GINT64_FORMAT " -> %d)\n", guidstr,gncTaxTableGetRefcount(table), count); gncTaxTableSetRefcount(table, count); } }
void tax_table_delete_table_cb (GtkButton *button, TaxTableWindow *ttw) { g_return_if_fail (ttw); if (!ttw->current_table) return; if (gncTaxTableGetRefcount (ttw->current_table) > 0) { char *message = g_strdup_printf (_("Tax table \"%s\" is in use. You cannot delete it."), gncTaxTableGetName (ttw->current_table)); gnc_error_dialog (ttw->dialog, "%s", message); g_free (message); return; } if (gnc_verify_dialog (ttw->dialog, FALSE, _("Are you sure you want to delete \"%s\"?"), gncTaxTableGetName (ttw->current_table))) { /* Ok, let's remove it */ gnc_suspend_gui_refresh (); gncTaxTableBeginEdit (ttw->current_table); gncTaxTableDestroy (ttw->current_table); ttw->current_table = NULL; ttw->current_entry = NULL; gnc_resume_gui_refresh (); } }
static xmlNodePtr taxtable_dom_tree_create (GncTaxTable *table) { xmlNodePtr ret, entries; GList *list; kvp_frame *kf; ret = xmlNewNode(NULL, BAD_CAST gnc_taxtable_string); xmlSetProp(ret, BAD_CAST "version", BAD_CAST taxtable_version_string); maybe_add_guid(ret, taxtable_guid_string, table); xmlAddChild(ret, text_to_dom_tree (taxtable_name_string, gncTaxTableGetName (table))); xmlAddChild(ret, int_to_dom_tree (taxtable_refcount_string, gncTaxTableGetRefcount (table))); xmlAddChild(ret, int_to_dom_tree (taxtable_invisible_string, gncTaxTableGetInvisible (table))); /* We should not be our own child */ if (gncTaxTableGetChild(table) != table) maybe_add_guid(ret, taxtable_child_string, gncTaxTableGetChild (table)); maybe_add_guid(ret, taxtable_parent_string, gncTaxTableGetParent (table)); entries = xmlNewChild (ret, NULL, BAD_CAST taxtable_entries_string, NULL); for (list = gncTaxTableGetEntries (table); list; list = list->next) { GncTaxTableEntry *entry = list->data; xmlAddChild(entries, ttentry_dom_tree_create (entry)); } kf = qof_instance_get_slots (QOF_INSTANCE(table)); if (kf) { xmlNodePtr kvpnode = kvp_frame_to_dom_tree(taxtable_slots_string, kf); if (kvpnode) { xmlAddChild(ret, kvpnode); } } return ret; }
static xmlNodePtr taxtable_dom_tree_create (GncTaxTable *table) { xmlNodePtr ret, entries; GList *list; ret = xmlNewNode(NULL, BAD_CAST gnc_taxtable_string); xmlSetProp(ret, BAD_CAST "version", BAD_CAST taxtable_version_string); maybe_add_guid(ret, taxtable_guid_string, table); xmlAddChild(ret, text_to_dom_tree (taxtable_name_string, gncTaxTableGetName (table))); xmlAddChild(ret, int_to_dom_tree (taxtable_refcount_string, gncTaxTableGetRefcount (table))); xmlAddChild(ret, int_to_dom_tree (taxtable_invisible_string, gncTaxTableGetInvisible (table))); /* We should not be our own child */ if (gncTaxTableGetChild(table) != table) maybe_add_guid(ret, taxtable_child_string, gncTaxTableGetChild (table)); maybe_add_guid(ret, taxtable_parent_string, gncTaxTableGetParent (table)); entries = xmlNewChild (ret, NULL, BAD_CAST taxtable_entries_string, NULL); for (list = gncTaxTableGetEntries (table); list; list = list->next) { GncTaxTableEntry *entry = static_cast<decltype(entry)>(list->data); xmlAddChild(entries, ttentry_dom_tree_create (entry)); } /* xmlAddChild won't do anything with a NULL, so tests are superfluous. */ xmlAddChild(ret, qof_instance_slots_to_dom_tree(taxtable_slots_string, QOF_INSTANCE(table))); return ret; }