From 0c5a2cbc90f26e380965807aacc3308d7da6b351 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Mon, 19 Dec 2011 00:47:11 +0000 Subject: [PATCH] [Bug #642276] Bayesian association with Sqlite Wraps the kvp_frame_set_slot_path with xaccAccountBeginEdit()/xaccAccountCommitEdit(). BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21742 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/import-export/import-match-map.c | 10 ++++++++-- src/import-export/import-utilities.c | 12 ++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/import-export/import-match-map.c b/src/import-export/import-match-map.c index de715413dd1..4f76a97ed7d 100644 --- a/src/import-export/import-match-map.c +++ b/src/import-export/import-match-map.c @@ -150,11 +150,14 @@ void gnc_imap_add_account (GncImportMatchMap *imap, const char *category, category = key; key = NULL; } + g_return_if_fail (acc != NULL); value = kvp_value_new_guid (xaccAccountGetGUID (acc)); g_return_if_fail (value != NULL); - + xaccAccountBeginEdit (imap->acc); kvp_frame_set_slot_path (imap->frame, value, IMAP_FRAME, category, key, NULL); + qof_instance_set_dirty (QOF_INSTANCE (imap->acc)); + xaccAccountCommit (imap->acc); kvp_value_delete (value); /* XXX Mark the account (or book) as dirty! */ @@ -475,7 +478,9 @@ void gnc_imap_add_account_bayes(GncImportMatchMap *imap, GList *tokens, Account return; } + g_return_if_fail (acc != NULL); account_fullname = gnc_account_get_full_name(acc); + xaccAccountBeginEdit (imap->acc); PINFO("account name: '%s'\n", account_fullname); @@ -524,13 +529,14 @@ void gnc_imap_add_account_bayes(GncImportMatchMap *imap, GList *tokens, Account */ kvp_frame_set_slot_path(imap->frame, new_value, IMAP_FRAME_BAYES, (char*)current_token->data, account_fullname, NULL); - /* kvp_frame_set_slot_path() copied the value so we * need to delete this one ;-) */ kvp_value_delete(new_value); } /* free up the account fullname string */ + qof_instance_set_dirty (QOF_INSTANCE (imap->acc)); + xaccAccountCommitEdit (imap->acc); g_free(account_fullname); LEAVE(" "); diff --git a/src/import-export/import-utilities.c b/src/import-export/import-utilities.c index be530cbc6ef..4d7756a7bf5 100644 --- a/src/import-export/import-utilities.c +++ b/src/import-export/import-utilities.c @@ -47,12 +47,18 @@ const gchar * gnc_import_get_acc_online_id(Account * account) return kvp_frame_get_string(frame, "online_id"); } +/* Used in the midst of editing a transaction; make it save the + * account data. */ void gnc_import_set_acc_online_id(Account * account, const gchar * string_value) { kvp_frame * frame; + g_return_if_fail (account != NULL); frame = xaccAccountGetSlots(account); + xaccAccountBeginEdit (account); kvp_frame_set_str(frame, "online_id", string_value); + qof_instance_set_dirty (QOF_INSTANCE (account)); + xaccAccountCommitEdit (account); } const gchar * gnc_import_get_trans_online_id(Transaction * transaction) @@ -61,7 +67,7 @@ const gchar * gnc_import_get_trans_online_id(Transaction * transaction) frame = xaccTransGetSlots(transaction); return kvp_frame_get_string(frame, "online_id"); } - +/* Not actually used */ void gnc_import_set_trans_online_id(Transaction * transaction, const gchar * string_value) { @@ -83,7 +89,9 @@ const gchar * gnc_import_get_split_online_id(Split * split) frame = xaccSplitGetSlots(split); return kvp_frame_get_string(frame, "online_id"); } - +/* Used several places in a transaction edit where many other + * parameters are also being set, so individual commits wouldn't be + * appropriate. */ void gnc_import_set_split_online_id(Split * split, const gchar * string_value) {