Skip to content

Commit

Permalink
[Bug #642276] Bayesian association with Sqlite
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jralls committed Dec 19, 2011
1 parent 343f17f commit 0c5a2cb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/import-export/import-match-map.c
Expand Up @@ -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! */
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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(" ");
Expand Down
12 changes: 10 additions & 2 deletions src/import-export/import-utilities.c
Expand Up @@ -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)
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand Down

0 comments on commit 0c5a2cb

Please sign in to comment.