r18490 - gnucash/trunk/src/engine - When closing the book, destroy all lots (found by valgrind)
Phil Longstaff
plongstaff at code.gnucash.org
Sat Dec 12 15:05:46 EST 2009
Author: plongstaff
Date: 2009-12-12 15:05:44 -0500 (Sat, 12 Dec 2009)
New Revision: 18490
Trac: http://svn.gnucash.org/trac/changeset/18490
Modified:
gnucash/trunk/src/engine/gnc-lot.c
Log:
When closing the book, destroy all lots (found by valgrind)
Modified: gnucash/trunk/src/engine/gnc-lot.c
===================================================================
--- gnucash/trunk/src/engine/gnc-lot.c 2009-12-12 00:15:50 UTC (rev 18489)
+++ gnucash/trunk/src/engine/gnc-lot.c 2009-12-12 20:05:44 UTC (rev 18490)
@@ -434,6 +434,26 @@
return node->data;
}
+/* When the book is being closed, destroy all lots */
+static void
+lot_destroy_book_end(GNCLot* lot)
+{
+ gnc_lot_begin_edit(lot);
+ while (lot->splits != NULL) {
+ gnc_lot_remove_split(lot, (Split*)lot->splits->data);
+ }
+ qof_instance_set_destroying(lot, TRUE);
+ gnc_lot_commit_edit(lot);
+}
+
+static void
+lot_book_end(QofBook* book)
+{
+ QofCollection *col;
+ col = qof_book_get_collection (book, GNC_ID_LOT);
+ qof_collection_foreach(col, (QofInstanceForeachCB)lot_destroy_book_end, NULL);
+}
+
/* ============================================================= */
static QofObject gncLotDesc =
@@ -443,7 +463,7 @@
.type_label = "Lot",
.create = (gpointer)gnc_lot_new,
.book_begin = NULL,
- .book_end = NULL,
+ .book_end = lot_book_end,
.is_dirty = qof_collection_is_dirty,
.mark_clean = qof_collection_mark_clean,
.foreach = qof_collection_foreach,
More information about the gnucash-changes
mailing list