r15944 - gnucash/trunk/src - Bug#431771: remove from SX deferred-instance list by value. Remove inexplicably-commented line from SX Instance Model.

Josh Sled jsled at cvs.gnucash.org
Fri Apr 20 17:24:09 EDT 2007


Author: jsled
Date: 2007-04-20 17:24:08 -0400 (Fri, 20 Apr 2007)
New Revision: 15944
Trac: http://svn.gnucash.org/trac/changeset/15944

Modified:
   gnucash/trunk/src/app-utils/gnc-sx-instance-model.c
   gnucash/trunk/src/engine/SchedXaction.c
Log:
Bug#431771: remove from SX deferred-instance list by value.  Remove inexplicably-commented line from SX Instance Model.


Modified: gnucash/trunk/src/app-utils/gnc-sx-instance-model.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-sx-instance-model.c	2007-04-20 18:54:19 UTC (rev 15943)
+++ gnucash/trunk/src/app-utils/gnc-sx-instance-model.c	2007-04-20 21:24:08 UTC (rev 15944)
@@ -370,7 +370,6 @@
             inst_date = xaccSchedXactionGetNextInstance(sx, postponed->data);
             seq_num = gnc_sx_get_instance_count(sx, postponed->data);
             inst = gnc_sx_instance_new(instances, SX_INSTANCE_STATE_POSTPONED, &inst_date, postponed->data, seq_num);
-            //inst->temporal_state = postponed->data;
             instances->instance_list = g_list_append(instances->instance_list, inst);
         }
     }

Modified: gnucash/trunk/src/engine/SchedXaction.c
===================================================================
--- gnucash/trunk/src/engine/SchedXaction.c	2007-04-20 18:54:19 UTC (rev 15943)
+++ gnucash/trunk/src/engine/SchedXaction.c	2007-04-20 21:24:08 UTC (rev 15944)
@@ -802,12 +802,14 @@
 
    if ( !tsd_a && !tsd_b )
       return 0;
+   if (tsd_a == tsd_b)
+      return 0;
    if ( !tsd_a )
       return 1;
    if ( !tsd_b )
       return -1;
    return g_date_compare( &tsd_a->last_date,
-                &tsd_b->last_date );
+                          &tsd_b->last_date );
 }
 
 /**
@@ -817,9 +819,9 @@
 void
 gnc_sx_add_defer_instance( SchedXaction *sx, void *deferStateData )
 {
-   sx->deferredList = g_list_insert_sorted( sx->deferredList,
-                   deferStateData,
-                   _temporal_state_data_cmp );
+    sx->deferredList = g_list_insert_sorted( sx->deferredList,
+                                             deferStateData,
+                                             _temporal_state_data_cmp );
 }
 
 /**
@@ -829,7 +831,17 @@
 void
 gnc_sx_remove_defer_instance( SchedXaction *sx, void *deferStateData )
 {
-   sx->deferredList = g_list_remove( sx->deferredList, deferStateData );
+    GList *found_by_value;
+
+    found_by_value = g_list_find_custom(
+        sx->deferredList, deferStateData, _temporal_state_data_cmp);
+    if (found_by_value == NULL) {
+        g_warning("unable to find deferred instance");
+        return;
+    }
+
+    gnc_sx_destroy_temporal_state(found_by_value->data);
+    sx->deferredList = g_list_delete_link(sx->deferredList, found_by_value);
 }
 
 /**



More information about the gnucash-changes mailing list