r21744 - gnucash/branches/2.4/src/import-export - [r21742][Bug #642276] Bayesian association with Sqlite

John Ralls jralls at code.gnucash.org
Sun Dec 18 20:26:54 EST 2011


Author: jralls
Date: 2011-12-18 20:26:54 -0500 (Sun, 18 Dec 2011)
New Revision: 21744
Trac: http://svn.gnucash.org/trac/changeset/21744

Modified:
   gnucash/branches/2.4/src/import-export/import-match-map.c
   gnucash/branches/2.4/src/import-export/import-utilities.c
Log:
[r21742][Bug #642276] Bayesian association with Sqlite

Wraps the kvp_frame_set_slot_path with xaccAccountBeginEdit()/xaccAccountCommitEdit().

Modified: gnucash/branches/2.4/src/import-export/import-match-map.c
===================================================================
--- gnucash/branches/2.4/src/import-export/import-match-map.c	2011-12-19 00:47:20 UTC (rev 21743)
+++ gnucash/branches/2.4/src/import-export/import-match-map.c	2011-12-19 01:26:54 UTC (rev 21744)
@@ -150,11 +150,14 @@
         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 @@
         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 @@
          */
         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(" ");

Modified: gnucash/branches/2.4/src/import-export/import-utilities.c
===================================================================
--- gnucash/branches/2.4/src/import-export/import-utilities.c	2011-12-19 00:47:20 UTC (rev 21743)
+++ gnucash/branches/2.4/src/import-export/import-utilities.c	2011-12-19 01:26:54 UTC (rev 21744)
@@ -47,12 +47,18 @@
     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 @@
     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 @@
     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)
 {



More information about the gnucash-changes mailing list