r23505 - gnucash/branches/2.4/src - [23466]Ensure that all KVP changes are properly marked dirty and committed.

Geert Janssens gjanssens at code.gnucash.org
Sat Dec 7 11:08:51 EST 2013


Author: gjanssens
Date: 2013-12-07 11:08:48 -0500 (Sat, 07 Dec 2013)
New Revision: 23505
Trac: http://svn.gnucash.org/trac/changeset/23505

Modified:
   gnucash/branches/2.4/src/app-utils/gnc-sx-instance-model.c
   gnucash/branches/2.4/src/engine/Split.c
   gnucash/branches/2.4/src/engine/Transaction.c
   gnucash/branches/2.4/src/import-export/import-match-map.c
   gnucash/branches/2.4/src/import-export/import-utilities.c
   gnucash/branches/2.4/src/register/ledger-core/split-register-model-save.c
Log:
[23466]Ensure that all KVP changes are properly marked dirty and committed.

Modified: gnucash/branches/2.4/src/app-utils/gnc-sx-instance-model.c
===================================================================
--- gnucash/branches/2.4/src/app-utils/gnc-sx-instance-model.c	2013-12-07 16:08:24 UTC (rev 23504)
+++ gnucash/branches/2.4/src/app-utils/gnc-sx-instance-model.c	2013-12-07 16:08:48 UTC (rev 23505)
@@ -1178,7 +1178,7 @@
                 g_string_free(exchange_rate_var_name, TRUE);
 
                 amt = gnc_numeric_mul(final, exchange_rate, 1000, GNC_HOW_RND_ROUND_HALF_UP);
-                xaccSplitSetAmount(copying_split, amt);
+                xaccSplitSetAmount(copying_split, amt); /* marks split dirty */
             }
 
             xaccSplitScrub(copying_split);
@@ -1197,7 +1197,11 @@
     {
         kvp_frame *txn_frame;
         txn_frame = xaccTransGetSlots(new_txn);
-        kvp_frame_set_guid(txn_frame, "from-sched-xaction", xaccSchedXactionGetGUID(creation_data->instance->parent->sx));
+        kvp_frame_set_guid(txn_frame, "from-sched-xaction",
+		  xaccSchedXactionGetGUID(creation_data->instance->parent->sx));
+/* The transaction was probably marked dirty by xaccTransSetCurrency,
+ * but just in case: */
+	qof_instance_set_dirty (QOF_INSTANCE (new_txn));
     }
 
     xaccTransCommitEdit(new_txn);

Modified: gnucash/branches/2.4/src/engine/Split.c
===================================================================
--- gnucash/branches/2.4/src/engine/Split.c	2013-12-07 16:08:24 UTC (rev 23504)
+++ gnucash/branches/2.4/src/engine/Split.c	2013-12-07 16:08:48 UTC (rev 23505)
@@ -2010,10 +2010,10 @@
     kvp_frame_set_gnc_numeric(frame, void_former_val_str,
                               xaccSplitGetValue(split));
 
+    /* Marking dirty handled by SetAmount etc. */
     xaccSplitSetAmount (split, zero);
     xaccSplitSetValue (split, zero);
     xaccSplitSetReconcile(split, VREC);
-
 }
 
 void
@@ -2026,6 +2026,7 @@
     xaccSplitSetReconcile(split, NREC);
     kvp_frame_set_slot(frame, void_former_amt_str, NULL);
     kvp_frame_set_slot(frame, void_former_val_str, NULL);
+    qof_instance_set_dirty (QOF_INSTANCE (split));
 }
 
 /********************************************************************\

Modified: gnucash/branches/2.4/src/engine/Transaction.c
===================================================================
--- gnucash/branches/2.4/src/engine/Transaction.c	2013-12-07 16:08:24 UTC (rev 23504)
+++ gnucash/branches/2.4/src/engine/Transaction.c	2013-12-07 16:08:48 UTC (rev 23505)
@@ -1635,6 +1635,7 @@
         kvp_value_delete(kvp_value);
     }
 
+    /* mark dirty and commit handled by SetDateInternal */
     xaccTransSetDateInternal(trans, &trans->date_posted,
                              gdate_to_timespec(date));
     set_gains_date_dirty (trans);
@@ -2177,13 +2178,13 @@
         xaccSplitSetAmount(s, gnc_numeric_neg(xaccSplitGetAmount(s)));
         xaccSplitSetValue(s, gnc_numeric_neg(xaccSplitGetValue(s)));
         xaccSplitSetReconcile(s, NREC);
-        qof_instance_set_dirty(QOF_INSTANCE(trans));
     });
 
     /* Now update the original with a pointer to the new one */
     kvp_val = kvp_value_new_guid(xaccTransGetGUID(trans));
     kvp_frame_set_slot_nc(orig->inst.kvp_data, TRANS_REVERSED_BY, kvp_val);
 
+    qof_instance_set_dirty(QOF_INSTANCE(trans));
     xaccTransCommitEdit(trans);
     return trans;
 }

Modified: gnucash/branches/2.4/src/import-export/import-match-map.c
===================================================================
--- gnucash/branches/2.4/src/import-export/import-match-map.c	2013-12-07 16:08:24 UTC (rev 23504)
+++ gnucash/branches/2.4/src/import-export/import-match-map.c	2013-12-07 16:08:48 UTC (rev 23505)
@@ -107,14 +107,14 @@
 void gnc_imap_clear (GncImportMatchMap *imap)
 {
     if (!imap) return;
-
+    xaccAccountBeginEdit (imap->acc);
     /* Clear the IMAP_FRAME kvp */
     kvp_frame_set_slot_path (imap->frame, NULL, IMAP_FRAME);
 
     /* Clear the bayes kvp, IMAP_FRAME_BAYES */
     kvp_frame_set_slot_path (imap->frame, NULL, IMAP_FRAME_BAYES);
-
-    /* XXX: mark the account (or book) as dirty! */
+    qof_instance_set_dirty (QOF_INSTANCE (imap->acc));
+    xaccAccountCommitEdit (imap->acc);
 }
 
 /** Look up an Account in the map */

Modified: gnucash/branches/2.4/src/import-export/import-utilities.c
===================================================================
--- gnucash/branches/2.4/src/import-export/import-utilities.c	2013-12-07 16:08:24 UTC (rev 23504)
+++ gnucash/branches/2.4/src/import-export/import-utilities.c	2013-12-07 16:08:48 UTC (rev 23505)
@@ -72,8 +72,11 @@
                                     const gchar * string_value)
 {
     kvp_frame * frame;
+    xaccTransBeginEdit (transaction);
     frame = xaccTransGetSlots(transaction);
     kvp_frame_set_str (frame, "online_id", string_value);
+    qof_instance_set_dirty (QOF_INSTANCE (transaction));
+    xaccTransCommitEdit (transaction);
 }
 
 gboolean gnc_import_trans_has_online_id(Transaction * transaction)
@@ -96,8 +99,10 @@
                                     const gchar * string_value)
 {
     kvp_frame * frame;
+    xaccTransBeginEdit (xaccSplitGetParent (split));
     frame = xaccSplitGetSlots(split);
     kvp_frame_set_str (frame, "online_id", string_value);
+    qof_instance_set_dirty (QOF_INSTANCE (split));
 }
 
 gboolean gnc_import_split_has_online_id(Split * split)

Modified: gnucash/branches/2.4/src/register/ledger-core/split-register-model-save.c
===================================================================
--- gnucash/branches/2.4/src/register/ledger-core/split-register-model-save.c	2013-12-07 16:08:24 UTC (rev 23504)
+++ gnucash/branches/2.4/src/register/ledger-core/split-register-model-save.c	2013-12-07 16:08:48 UTC (rev 23505)
@@ -660,6 +660,7 @@
 
     /* set the actual account to the fake account for these templates */
     xaccAccountInsertSplit (template_acc, sd->split);
+    qof_instance_set_dirty (QOF_INSTANCE (sd->split));
 }
 
 static void
@@ -737,6 +738,7 @@
     DEBUG ("kvp_frame  after: %s\n", kvp_frame_to_string (kvpf));
 
     /* set the amount to an innocuous value */
+    /* Note that this marks the split dirty */
     xaccSplitSetValue (sd->split, gnc_numeric_create (0, 1));
 
     sd->handled_dc = TRUE;
@@ -768,6 +770,7 @@
     DEBUG ("kvp_frame  after: %s\n", kvp_frame_to_string (kvpf));
 
     /* set the shares to an innocuous value */
+    /* Note that this marks the split dirty */
     xaccSplitSetSharePriceAndAmount (sd->split,
                                      gnc_numeric_create (0, 1),
                                      gnc_numeric_create (0, 1));



More information about the gnucash-changes mailing list