static GncEntry* dom_tree_to_entry (xmlNodePtr node, QofBook *book) { struct entry_pdata entry_pdata; gboolean successful; entry_pdata.entry = gncEntryCreate(book); entry_pdata.book = book; entry_pdata.acc = NULL; gncEntryBeginEdit (entry_pdata.entry); successful = dom_tree_generic_parse (node, entry_handlers_v2, &entry_pdata); if (entry_pdata.acc != NULL) { if (gncEntryGetBill (entry_pdata.entry)) gncEntrySetBillAccount (entry_pdata.entry, entry_pdata.acc); else gncEntrySetInvAccount (entry_pdata.entry, entry_pdata.acc); } if (successful) gncEntryCommitEdit (entry_pdata.entry); else { PERR ("failed to parse entry tree"); gncEntryDestroy (entry_pdata.entry); entry_pdata.entry = NULL; } return entry_pdata.entry; }
static gboolean entry_guid_handler (xmlNodePtr node, gpointer entry_pdata) { struct entry_pdata *pdata = entry_pdata; GncGUID *guid; GncEntry *entry; guid = dom_tree_to_guid(node); g_return_val_if_fail (guid, FALSE); entry = gncEntryLookup (pdata->book, guid); if (entry) { gncEntryDestroy (pdata->entry); pdata->entry = entry; gncEntryBeginEdit (entry); } else { gncEntrySetGUID(pdata->entry, guid); } g_free(guid); return TRUE; }
static void destroy_entry_on_book_close(QofInstance *ent, gpointer data) { GncEntry* entry = GNC_ENTRY(ent); gncEntryBeginEdit(entry); gncEntryDestroy(entry); }