[Gnucash-changes] r13955 - gnucash/trunk/lib/libqof/qof - Make qof_commit_edit() (and macro version) call qof_backend_run_commit()

Chris Shoemaker chris at cvs.gnucash.org
Sun May 7 23:02:16 EDT 2006


Author: chris
Date: 2006-05-07 23:02:15 -0400 (Sun, 07 May 2006)
New Revision: 13955
Trac: http://svn.gnucash.org/trac/changeset/13955

Modified:
   gnucash/trunk/lib/libqof/qof/qofutil.c
   gnucash/trunk/lib/libqof/qof/qofutil.h
Log:
   Make qof_commit_edit() (and macro version) call qof_backend_run_commit()
   instead of qof_backend_run_begin().
   Minor cleanups of qof_commit_edit() and qof_begin_edit().


Modified: gnucash/trunk/lib/libqof/qof/qofutil.c
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofutil.c	2006-05-08 02:54:03 UTC (rev 13954)
+++ gnucash/trunk/lib/libqof/qof/qofutil.c	2006-05-08 03:02:15 UTC (rev 13955)
@@ -231,14 +231,18 @@
 {
   QofBackend * be;
 
-  if (!inst) { return FALSE; }
-  (inst->editlevel)++;
-  if (1 < inst->editlevel) { return FALSE; }
-  if (0 >= inst->editlevel) { inst->editlevel = 1; }
+  if (!inst) return FALSE;
+  inst->editlevel++;
+  if (1 < inst->editlevel) return FALSE;
+  if (0 >= inst->editlevel) 
+      inst->editlevel = 1;
+
   be = qof_book_get_backend (inst->book);
-    if (be && qof_backend_begin_exists(be)) {
-     qof_backend_run_begin(be, inst);
-  } else { inst->dirty = TRUE; }
+  if (be && qof_backend_begin_exists(be))
+      qof_backend_run_begin(be, inst);
+  else
+      inst->dirty = TRUE; 
+  
   return TRUE;
 }
 
@@ -246,18 +250,21 @@
 {
   QofBackend * be;
 
-  if (!inst) { return FALSE; }
-  (inst->editlevel)--;
-  if (0 < inst->editlevel) { return FALSE; }
+  if (!inst) return FALSE;
+  inst->editlevel--;
+  if (0 < inst->editlevel) return FALSE;
+
   if ((-1 == inst->editlevel) && inst->dirty)
   {
-    be = qof_book_get_backend ((inst)->book);
-    if (be && qof_backend_begin_exists(be)) {
-     qof_backend_run_begin(be, inst);
+    be = qof_book_get_backend (inst->book);
+    if (be && qof_backend_commit_exists(be)) {
+        qof_backend_run_commit(be, inst);
     }
-    inst->editlevel = 0;
   }
-  if (0 > inst->editlevel) { inst->editlevel = 0; }
+  if (0 > inst->editlevel) { 
+      PERR ("unbalanced call - resetting (was %d)", inst->editlevel);
+      inst->editlevel = 0;
+  }
   return TRUE;
 }
 

Modified: gnucash/trunk/lib/libqof/qof/qofutil.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofutil.h	2006-05-08 02:54:03 UTC (rev 13954)
+++ gnucash/trunk/lib/libqof/qof/qofutil.h	2006-05-08 03:02:15 UTC (rev 13955)
@@ -354,12 +354,12 @@
   /* The pricedb suffers from delayed update...     */          \
   /* This may be setting a bad precedent for other types, I fear. */ \
   /* Other types probably really should handle begin like this. */ \
-  if ((-1 == (inst)->editlevel) && (inst)->dirty)                \
+  if ((-1 == (inst)->editlevel) && (inst)->dirty)                   \
   {                                                              \
     QofBackend * be;                                             \
     be = qof_book_get_backend ((inst)->book);                    \
-    if (be && qof_backend_begin_exists(be)) {                    \
-      qof_backend_run_begin(be, (inst));                         \
+    if (be && qof_backend_commit_exists(be)) {                   \
+        qof_backend_run_commit(be, (inst));                      \
     }                                                            \
     (inst)->editlevel = 0;                                       \
   }                                                              \



More information about the gnucash-changes mailing list