r23466 - gnucash/trunk/src - Ensure that all KVP changes are properly marked dirty and committed.

John Ralls jralls at code.gnucash.org
Sat Nov 30 20:30:04 EST 2013


Author: jralls
Date: 2013-11-30 20:30:03 -0500 (Sat, 30 Nov 2013)
New Revision: 23466
Trac: http://svn.gnucash.org/trac/changeset/23466

Modified:
   gnucash/trunk/src/app-utils/gnc-sx-instance-model.c
   gnucash/trunk/src/engine/Split.c
   gnucash/trunk/src/engine/Transaction.c
   gnucash/trunk/src/import-export/import-match-map.c
   gnucash/trunk/src/import-export/import-utilities.c
   gnucash/trunk/src/register/ledger-core/split-register-model-save.c
   gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c
Log:
Ensure that all KVP changes are properly marked dirty and committed.

Modified: gnucash/trunk/src/app-utils/gnc-sx-instance-model.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-sx-instance-model.c	2013-11-30 16:03:44 UTC (rev 23465)
+++ gnucash/trunk/src/app-utils/gnc-sx-instance-model.c	2013-12-01 01:30:03 UTC (rev 23466)
@@ -1198,7 +1198,7 @@
 
 
                 g_debug("amount is %s for memo split '%s'", gnc_numeric_to_string (amt), xaccSplitGetMemo (copying_split));
-                xaccSplitSetAmount(copying_split, amt);
+                xaccSplitSetAmount(copying_split, amt); /* marks split dirty */
             }
 
             xaccSplitScrub(copying_split);
@@ -1217,7 +1217,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/trunk/src/engine/Split.c
===================================================================
--- gnucash/trunk/src/engine/Split.c	2013-11-30 16:03:44 UTC (rev 23465)
+++ gnucash/trunk/src/engine/Split.c	2013-12-01 01:30:03 UTC (rev 23466)
@@ -1943,10 +1943,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
@@ -1959,6 +1959,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/trunk/src/engine/Transaction.c
===================================================================
--- gnucash/trunk/src/engine/Transaction.c	2013-11-30 16:03:44 UTC (rev 23465)
+++ gnucash/trunk/src/engine/Transaction.c	2013-12-01 01:30:03 UTC (rev 23466)
@@ -1857,6 +1857,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);
@@ -2480,13 +2481,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/trunk/src/import-export/import-match-map.c
===================================================================
--- gnucash/trunk/src/import-export/import-match-map.c	2013-11-30 16:03:44 UTC (rev 23465)
+++ gnucash/trunk/src/import-export/import-match-map.c	2013-12-01 01:30:03 UTC (rev 23466)
@@ -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/trunk/src/import-export/import-utilities.c
===================================================================
--- gnucash/trunk/src/import-export/import-utilities.c	2013-11-30 16:03:44 UTC (rev 23465)
+++ gnucash/trunk/src/import-export/import-utilities.c	2013-12-01 01:30:03 UTC (rev 23466)
@@ -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/trunk/src/register/ledger-core/split-register-model-save.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-model-save.c	2013-11-30 16:03:44 UTC (rev 23465)
+++ gnucash/trunk/src/register/ledger-core/split-register-model-save.c	2013-12-01 01:30:03 UTC (rev 23466)
@@ -683,6 +683,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
@@ -760,6 +761,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;
@@ -791,6 +793,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));

Modified: gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c
===================================================================
--- gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c	2013-11-30 16:03:44 UTC (rev 23465)
+++ gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c	2013-12-01 01:30:03 UTC (rev 23466)
@@ -1816,7 +1816,9 @@
         // As this is an invoice report with some owner, we will try to look up the
         // chosen output directory from the print settings and store it again in the owner kvp.
         GtkPrintSettings *print_settings = gnc_print_get_settings();
-        if (print_settings && gtk_print_settings_has_key(print_settings, GNC_GTK_PRINT_SETTINGS_EXPORT_DIR))
+        if (print_settings &&
+	    gtk_print_settings_has_key(print_settings,
+				       GNC_GTK_PRINT_SETTINGS_EXPORT_DIR))
         {
             const char* dirname = gtk_print_settings_get(print_settings,
                                   GNC_GTK_PRINT_SETTINGS_EXPORT_DIR);
@@ -1824,11 +1826,14 @@
             if (g_file_test(dirname, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
             {
                 QofInstance *qofinstance = qofOwnerGetOwner(owner);
-                //gncOwnerBeginEdit(owner);
-                kvp_frame_set_string(kvp, KVP_OWNER_EXPORT_PDF_DIRNAME, dirname);
                 if (qofinstance)
+		{
+		    gncOwnerBeginEdit(owner);
+		    kvp_frame_set_string(kvp, KVP_OWNER_EXPORT_PDF_DIRNAME,
+					 dirname);
                     qof_instance_set_dirty(qofinstance);
-                // shoot... there is no such thing as: gncOwnerCommitEdit(owner);
+		    qof_commit_edit (qofinstance);
+		}
             }
         }
     }



More information about the gnucash-changes mailing list