r15950 - gnucash/trunk/src/engine - Bug#431435: guard against dirtying the SX/book when setting to the same values the SX objects already contain.

Josh Sled jsled at cvs.gnucash.org
Sat Apr 21 11:30:48 EDT 2007


Author: jsled
Date: 2007-04-21 11:30:47 -0400 (Sat, 21 Apr 2007)
New Revision: 15950
Trac: http://svn.gnucash.org/trac/changeset/15950

Modified:
   gnucash/trunk/src/engine/SchedXaction.c
Log:
Bug#431435: guard against dirtying the SX/book when setting to the same values the SX objects already contain.


Modified: gnucash/trunk/src/engine/SchedXaction.c
===================================================================
--- gnucash/trunk/src/engine/SchedXaction.c	2007-04-21 14:08:08 UTC (rev 15949)
+++ gnucash/trunk/src/engine/SchedXaction.c	2007-04-21 15:30:47 UTC (rev 15950)
@@ -346,10 +346,13 @@
 }
 
 void
-xaccSchedXactionSetLastOccurDate( SchedXaction *sx, GDate* newLastOccur )
+xaccSchedXactionSetLastOccurDate(SchedXaction *sx, GDate* new_last_occur)
 {
+  if (g_date_valid(&sx->last_date)
+      && g_date_compare(&sx->last_date, new_last_occur) == 0)
+    return;
   gnc_sx_begin_edit(sx);
-  sx->last_date = *newLastOccur;
+  sx->last_date = *new_last_occur;
   qof_instance_set_dirty(&sx->inst);
   gnc_sx_commit_edit(sx);
 }
@@ -367,10 +370,12 @@
 }
 
 void
-xaccSchedXactionSetNumOccur( SchedXaction *sx, gint newNum )
+xaccSchedXactionSetNumOccur(SchedXaction *sx, gint new_num)
 {
+  if (sx->num_occurances_total == new_num)
+    return;
   gnc_sx_begin_edit(sx);
-  sx->num_occurances_remain = sx->num_occurances_total = newNum;
+  sx->num_occurances_remain = sx->num_occurances_total = new_num;
   qof_instance_set_dirty(&sx->inst);
   gnc_sx_commit_edit(sx);
 }
@@ -382,18 +387,20 @@
 }
 
 void
-xaccSchedXactionSetRemOccur( SchedXaction *sx,
-                             gint numRemain )
+xaccSchedXactionSetRemOccur(SchedXaction *sx, gint num_remain)
 {
   /* FIXME This condition can be tightened up */
-  if ( numRemain > sx->num_occurances_total ) 
+  if (num_remain > sx->num_occurances_total)
   {
-    g_warning("The number remaining is greater than the total occurrences");
+    g_warning("number remaining [%d] > total occurrences [%d]",
+              num_remain, sx->num_occurances_total);
   }
   else
   {
+    if (num_remain == sx->num_occurances_remain)
+      return;
     gnc_sx_begin_edit(sx);
-    sx->num_occurances_remain = numRemain;
+    sx->num_occurances_remain = num_remain;
     qof_instance_set_dirty(&sx->inst);
     gnc_sx_commit_edit(sx);
   }
@@ -620,10 +627,12 @@
 }
 
 void
-gnc_sx_set_instance_count( SchedXaction *sx, gint instanceNum )
+gnc_sx_set_instance_count(SchedXaction *sx, gint instance_num)
 {
-  g_return_if_fail( sx );
-  sx->instance_num = instanceNum;
+  g_return_if_fail(sx);
+  if (sx->instance_num == instance_num)
+    return;
+  sx->instance_num = instance_num;
 }
 
 GList *



More information about the gnucash-changes mailing list