mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Revert 18490/18491/18527 - I'm not sure it's actually deleting the objects without affecting the database.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18589 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
3d8123287f
commit
fbdcd66a91
@ -997,7 +997,6 @@ xaccFreeAccount (Account *acc)
|
|||||||
{
|
{
|
||||||
AccountPrivate *priv;
|
AccountPrivate *priv;
|
||||||
GList *lp;
|
GList *lp;
|
||||||
gboolean shutting_down = qof_book_shutting_down(qof_instance_get_book(acc));
|
|
||||||
|
|
||||||
g_return_if_fail(GNC_IS_ACCOUNT(acc));
|
g_return_if_fail(GNC_IS_ACCOUNT(acc));
|
||||||
|
|
||||||
@ -1016,8 +1015,6 @@ xaccFreeAccount (Account *acc)
|
|||||||
/* remove lots -- although these should be gone by now. */
|
/* remove lots -- although these should be gone by now. */
|
||||||
if (priv->lots)
|
if (priv->lots)
|
||||||
{
|
{
|
||||||
/* If shutting down, just drop lots - don't worry about nicities. */
|
|
||||||
if (!shutting_down) {
|
|
||||||
PERR (" instead of calling xaccFreeAccount(), please call \n"
|
PERR (" instead of calling xaccFreeAccount(), please call \n"
|
||||||
" xaccAccountBeginEdit(); xaccAccountDestroy(); \n");
|
" xaccAccountBeginEdit(); xaccAccountDestroy(); \n");
|
||||||
|
|
||||||
@ -1026,7 +1023,6 @@ xaccFreeAccount (Account *acc)
|
|||||||
GNCLot *lot = lp->data;
|
GNCLot *lot = lp->data;
|
||||||
gnc_lot_destroy (lot);
|
gnc_lot_destroy (lot);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
g_list_free (priv->lots);
|
g_list_free (priv->lots);
|
||||||
priv->lots = NULL;
|
priv->lots = NULL;
|
||||||
}
|
}
|
||||||
@ -1037,10 +1033,7 @@ xaccFreeAccount (Account *acc)
|
|||||||
* check once we know the warning isn't occurring any more. */
|
* check once we know the warning isn't occurring any more. */
|
||||||
if (priv->splits)
|
if (priv->splits)
|
||||||
{
|
{
|
||||||
GList *slist = priv->splits;
|
GList *slist;
|
||||||
|
|
||||||
/* If shutting down, just drop lots - don't worry about nicities. */
|
|
||||||
if (!shutting_down) {
|
|
||||||
PERR (" instead of calling xaccFreeAccount(), please call \n"
|
PERR (" instead of calling xaccFreeAccount(), please call \n"
|
||||||
" xaccAccountBeginEdit(); xaccAccountDestroy(); \n");
|
" xaccAccountBeginEdit(); xaccAccountDestroy(); \n");
|
||||||
|
|
||||||
@ -1052,19 +1045,8 @@ xaccFreeAccount (Account *acc)
|
|||||||
g_assert(xaccSplitGetAccount(s) == acc);
|
g_assert(xaccSplitGetAccount(s) == acc);
|
||||||
xaccSplitDestroy (s);
|
xaccSplitDestroy (s);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
/* The book is being shut down. Just break the link from the split
|
|
||||||
to this account. */
|
|
||||||
for (lp = priv->splits; lp; lp = lp->next) {
|
|
||||||
Split *s = (Split *) lp->data;
|
|
||||||
s->acc = NULL;
|
|
||||||
s->orig_acc = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_list_free(slist);
|
g_list_free(slist);
|
||||||
if (!shutting_down && priv->splits != NULL) {
|
g_assert(priv->splits == NULL);
|
||||||
PERR("priv->splits != NULL\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CACHE_REPLACE(priv->accountName, NULL);
|
CACHE_REPLACE(priv->accountName, NULL);
|
||||||
@ -1153,11 +1135,8 @@ xaccAccountCommitEdit (Account *acc)
|
|||||||
{
|
{
|
||||||
GList *lp, *slist;
|
GList *lp, *slist;
|
||||||
QofCollection *col;
|
QofCollection *col;
|
||||||
gboolean shutting_down;
|
|
||||||
|
|
||||||
qof_instance_increase_editlevel(acc);
|
qof_instance_increase_editlevel(acc);
|
||||||
book = qof_instance_get_book(acc);
|
|
||||||
shutting_down = qof_book_shutting_down(book);
|
|
||||||
|
|
||||||
/* First, recursively free children */
|
/* First, recursively free children */
|
||||||
xaccFreeAccountChildren(acc);
|
xaccFreeAccountChildren(acc);
|
||||||
@ -1166,13 +1145,11 @@ xaccAccountCommitEdit (Account *acc)
|
|||||||
acc, priv->accountName ? priv->accountName : "(null)");
|
acc, priv->accountName ? priv->accountName : "(null)");
|
||||||
|
|
||||||
slist = g_list_copy(priv->splits);
|
slist = g_list_copy(priv->splits);
|
||||||
if (!shutting_down) {
|
|
||||||
for (lp = slist; lp; lp = lp->next)
|
for (lp = slist; lp; lp = lp->next)
|
||||||
{
|
{
|
||||||
Split *s = lp->data;
|
Split *s = lp->data;
|
||||||
xaccSplitDestroy (s);
|
xaccSplitDestroy (s);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
g_list_free(slist);
|
g_list_free(slist);
|
||||||
/* It turns out there's a case where this assertion does not hold:
|
/* It turns out there's a case where this assertion does not hold:
|
||||||
When the user tries to delete an Imbalance account, while also
|
When the user tries to delete an Imbalance account, while also
|
||||||
@ -1182,7 +1159,8 @@ xaccAccountCommitEdit (Account *acc)
|
|||||||
g_assert(priv->splits == NULL || qof_book_shutting_down(acc->inst.book));
|
g_assert(priv->splits == NULL || qof_book_shutting_down(acc->inst.book));
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!shutting_down) {
|
book = qof_instance_get_book(acc);
|
||||||
|
if (!qof_book_shutting_down(book)) {
|
||||||
col = qof_book_get_collection(book, GNC_ID_TRANS);
|
col = qof_book_get_collection(book, GNC_ID_TRANS);
|
||||||
qof_collection_foreach(col, destroy_pending_splits_for_account, acc);
|
qof_collection_foreach(col, destroy_pending_splits_for_account, acc);
|
||||||
}
|
}
|
||||||
@ -1588,10 +1566,8 @@ gnc_account_remove_split (Account *acc, Split *s)
|
|||||||
// And send the account-based event, too
|
// And send the account-based event, too
|
||||||
qof_event_gen(&acc->inst, GNC_EVENT_ITEM_REMOVED, s);
|
qof_event_gen(&acc->inst, GNC_EVENT_ITEM_REMOVED, s);
|
||||||
|
|
||||||
if (!qof_book_shutting_down(qof_instance_get_book(acc))) {
|
|
||||||
priv->balance_dirty = TRUE;
|
priv->balance_dirty = TRUE;
|
||||||
xaccAccountRecomputeBalance(acc);
|
xaccAccountRecomputeBalance(acc);
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4632,22 +4608,6 @@ xaccAccountForEachTransaction(const Account *acc, TransactionCallback proc,
|
|||||||
return xaccAccountStagedTransactionTraversal(acc, 42, proc, data);
|
return xaccAccountStagedTransactionTraversal(acc, 42, proc, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
account_book_end(QofBook* book)
|
|
||||||
{
|
|
||||||
QofCollection *col;
|
|
||||||
Account *root;
|
|
||||||
|
|
||||||
col = qof_book_get_collection (book, GNC_ID_ROOT_ACCOUNT);
|
|
||||||
root = gnc_coll_get_root_account (col);
|
|
||||||
if (root != NULL) {
|
|
||||||
xaccAccountBeginEdit(root);
|
|
||||||
xaccAccountDestroy(root);
|
|
||||||
}
|
|
||||||
col = qof_book_get_collection (book, GNC_ID_ACCOUNT);
|
|
||||||
printf("Accounts left: %d\n", qof_collection_count(col));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================================ */
|
/* ================================================================ */
|
||||||
/* QofObject function implementation and registration */
|
/* QofObject function implementation and registration */
|
||||||
|
|
||||||
@ -4657,7 +4617,7 @@ static QofObject account_object_def = {
|
|||||||
.type_label = "Account",
|
.type_label = "Account",
|
||||||
.create = (gpointer)xaccMallocAccount,
|
.create = (gpointer)xaccMallocAccount,
|
||||||
.book_begin = NULL,
|
.book_begin = NULL,
|
||||||
.book_end = account_book_end,
|
.book_end = NULL,
|
||||||
.is_dirty = qof_collection_is_dirty,
|
.is_dirty = qof_collection_is_dirty,
|
||||||
.mark_clean = qof_collection_mark_clean,
|
.mark_clean = qof_collection_mark_clean,
|
||||||
.foreach = qof_collection_foreach,
|
.foreach = qof_collection_foreach,
|
||||||
|
@ -514,20 +514,17 @@ void
|
|||||||
xaccSplitCommitEdit(Split *s)
|
xaccSplitCommitEdit(Split *s)
|
||||||
{
|
{
|
||||||
Account *acc, *orig_acc;
|
Account *acc, *orig_acc;
|
||||||
gboolean shutting_down = qof_book_shutting_down(qof_instance_get_book(s));
|
|
||||||
|
|
||||||
g_return_if_fail(s);
|
g_return_if_fail(s);
|
||||||
if (!qof_instance_is_dirty(QOF_INSTANCE(s)) && !shutting_down) {
|
if (!qof_instance_is_dirty(QOF_INSTANCE(s)))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
orig_acc = s->orig_acc;
|
orig_acc = s->orig_acc;
|
||||||
acc = s->acc;
|
acc = s->acc;
|
||||||
/* Remove from lot (but only if it hasn't been moved to
|
/* Remove from lot (but only if it hasn't been moved to
|
||||||
new lot already) */
|
new lot already) */
|
||||||
if (s->lot && (s->lot->account != acc || qof_instance_get_destroying(s))) {
|
if (s->lot && (s->lot->account != acc || qof_instance_get_destroying(s)))
|
||||||
gnc_lot_remove_split (s->lot, s);
|
gnc_lot_remove_split (s->lot, s);
|
||||||
}
|
|
||||||
|
|
||||||
/* Possibly remove the split from the original account... */
|
/* Possibly remove the split from the original account... */
|
||||||
if (orig_acc && (orig_acc != acc || qof_instance_get_destroying(s))) {
|
if (orig_acc && (orig_acc != acc || qof_instance_get_destroying(s))) {
|
||||||
@ -537,7 +534,7 @@ xaccSplitCommitEdit(Split *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ... and insert it into the new account if needed */
|
/* ... and insert it into the new account if needed */
|
||||||
if (acc && (orig_acc != acc) && !qof_instance_get_destroying(s) && !shutting_down) {
|
if (acc && (orig_acc != acc) && !qof_instance_get_destroying(s)) {
|
||||||
if (gnc_account_insert_split(acc, s)) {
|
if (gnc_account_insert_split(acc, s)) {
|
||||||
/* If the split's lot belonged to some other account, we
|
/* If the split's lot belonged to some other account, we
|
||||||
leave it so. */
|
leave it so. */
|
||||||
@ -568,7 +565,7 @@ xaccSplitCommitEdit(Split *s)
|
|||||||
qof_commit_edit_part2(QOF_INSTANCE(s), commit_err, NULL,
|
qof_commit_edit_part2(QOF_INSTANCE(s), commit_err, NULL,
|
||||||
(void (*) (QofInstance *)) xaccFreeSplit);
|
(void (*) (QofInstance *)) xaccFreeSplit);
|
||||||
|
|
||||||
if (acc && !shutting_down) {
|
if (acc) {
|
||||||
g_object_set(acc, "sort-dirty", TRUE, "balance-dirty", TRUE, NULL);
|
g_object_set(acc, "sort-dirty", TRUE, "balance-dirty", TRUE, NULL);
|
||||||
xaccAccountRecomputeBalance(acc);
|
xaccAccountRecomputeBalance(acc);
|
||||||
}
|
}
|
||||||
@ -1119,10 +1116,8 @@ xaccSplitDestroy (Split *split)
|
|||||||
acc = split->acc;
|
acc = split->acc;
|
||||||
trans = split->parent;
|
trans = split->parent;
|
||||||
if (acc && !qof_instance_get_destroying(acc)
|
if (acc && !qof_instance_get_destroying(acc)
|
||||||
&& xaccTransGetReadOnly(trans)
|
&& xaccTransGetReadOnly(trans))
|
||||||
&& !qof_book_shutting_down(qof_instance_get_book(split))) {
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
xaccTransBeginEdit(trans);
|
xaccTransBeginEdit(trans);
|
||||||
ed.node = split;
|
ed.node = split;
|
||||||
|
@ -334,11 +334,6 @@ xaccTransSortSplits (Transaction *trans)
|
|||||||
GList *node, *new_list = NULL;
|
GList *node, *new_list = NULL;
|
||||||
Split *split;
|
Split *split;
|
||||||
|
|
||||||
/* Don't bother if shutting down */
|
|
||||||
if (qof_book_shutting_down(qof_instance_get_book(trans))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* first debits */
|
/* first debits */
|
||||||
for (node = trans->splits; node; node = node->next) {
|
for (node = trans->splits; node; node = node->next) {
|
||||||
split = node->data;
|
split = node->data;
|
||||||
@ -456,8 +451,6 @@ xaccFreeTransaction (Transaction *trans)
|
|||||||
{
|
{
|
||||||
GList *node;
|
GList *node;
|
||||||
|
|
||||||
if (qof_book_shutting_down(qof_instance_get_book(trans)))
|
|
||||||
PINFO("xaccFreeTransaction(%p)\n", trans);
|
|
||||||
if (!trans) return;
|
if (!trans) return;
|
||||||
|
|
||||||
ENTER ("(addr=%p)", trans);
|
ENTER ("(addr=%p)", trans);
|
||||||
@ -964,14 +957,10 @@ xaccTransDestroy (Transaction *trans)
|
|||||||
{
|
{
|
||||||
if (!trans) return;
|
if (!trans) return;
|
||||||
|
|
||||||
if (qof_book_shutting_down(qof_instance_get_book(trans)))
|
|
||||||
PINFO("xaccTransDestroy(%p)\n", trans);
|
|
||||||
if (!xaccTransGetReadOnly (trans) ||
|
if (!xaccTransGetReadOnly (trans) ||
|
||||||
qof_book_shutting_down(qof_instance_get_book(trans))) {
|
qof_book_shutting_down(qof_instance_get_book(trans))) {
|
||||||
xaccTransBeginEdit(trans);
|
xaccTransBeginEdit(trans);
|
||||||
qof_instance_set_destroying(trans, TRUE);
|
qof_instance_set_destroying(trans, TRUE);
|
||||||
if (qof_book_shutting_down(qof_instance_get_book(trans)))
|
|
||||||
PINFO("xaccTransDestroy(%p): set destroying\n", trans);
|
|
||||||
xaccTransCommitEdit(trans);
|
xaccTransCommitEdit(trans);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1002,9 +991,6 @@ do_destroy (Transaction *trans)
|
|||||||
SplitList *node;
|
SplitList *node;
|
||||||
gboolean shutting_down = qof_book_shutting_down(qof_instance_get_book(trans));
|
gboolean shutting_down = qof_book_shutting_down(qof_instance_get_book(trans));
|
||||||
|
|
||||||
if (shutting_down)
|
|
||||||
PINFO("do_destroy(%p)\n", trans);
|
|
||||||
|
|
||||||
/* If there are capital-gains transactions associated with this,
|
/* If there are capital-gains transactions associated with this,
|
||||||
* they need to be destroyed too. */
|
* they need to be destroyed too. */
|
||||||
destroy_gains (trans);
|
destroy_gains (trans);
|
||||||
@ -1016,17 +1002,7 @@ do_destroy (Transaction *trans)
|
|||||||
qof_event_gen (&trans->inst, QOF_EVENT_DESTROY, NULL);
|
qof_event_gen (&trans->inst, QOF_EVENT_DESTROY, NULL);
|
||||||
|
|
||||||
/* We only own the splits that still think they belong to us. */
|
/* We only own the splits that still think they belong to us. */
|
||||||
if (shutting_down) {
|
trans->splits = g_list_copy(trans->splits);
|
||||||
while (trans->splits != NULL) {
|
|
||||||
Split* s;
|
|
||||||
node = g_list_first(trans->splits);
|
|
||||||
s = node->data;
|
|
||||||
trans->splits = g_list_remove_link(trans->splits, node);
|
|
||||||
xaccSplitDestroy(s);
|
|
||||||
xaccSplitCommitEdit(s);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// trans->splits = g_list_copy(trans->splits);
|
|
||||||
for (node = trans->splits; node; node = node->next) {
|
for (node = trans->splits; node; node = node->next) {
|
||||||
Split *s = node->data;
|
Split *s = node->data;
|
||||||
if (s->parent == trans) {
|
if (s->parent == trans) {
|
||||||
@ -1034,7 +1010,6 @@ do_destroy (Transaction *trans)
|
|||||||
xaccSplitCommitEdit(s);
|
xaccSplitCommitEdit(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
g_list_free (trans->splits);
|
g_list_free (trans->splits);
|
||||||
trans->splits = NULL;
|
trans->splits = NULL;
|
||||||
xaccFreeTransaction (trans);
|
xaccFreeTransaction (trans);
|
||||||
@ -1043,7 +1018,7 @@ do_destroy (Transaction *trans)
|
|||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
|
|
||||||
/* Temporary hack for data consistency */
|
/* Temporary hack for data consitency */
|
||||||
static int scrub_data = 1;
|
static int scrub_data = 1;
|
||||||
void xaccEnableDataScrubbing(void) { scrub_data = 1; }
|
void xaccEnableDataScrubbing(void) { scrub_data = 1; }
|
||||||
void xaccDisableDataScrubbing(void) { scrub_data = 0; }
|
void xaccDisableDataScrubbing(void) { scrub_data = 0; }
|
||||||
@ -1151,7 +1126,7 @@ xaccTransCommitEdit (Transaction *trans)
|
|||||||
* change the number of splits in this transaction, and the
|
* change the number of splits in this transaction, and the
|
||||||
* transaction itself might be deleted. This is also why
|
* transaction itself might be deleted. This is also why
|
||||||
* we can't really enforce these constraints elsewhere: they
|
* we can't really enforce these constraints elsewhere: they
|
||||||
* can cause pointers to splits and transactions to disappear out
|
* can cause pointers to splits and transactions to disapear out
|
||||||
* from under the holder.
|
* from under the holder.
|
||||||
*/
|
*/
|
||||||
if (!qof_instance_get_destroying(trans) && scrub_data &&
|
if (!qof_instance_get_destroying(trans) && scrub_data &&
|
||||||
@ -2038,42 +2013,6 @@ xaccTransFindSplitByAccount(const Transaction *trans, const Account *acc)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
trans_destroy(Transaction* trans)
|
|
||||||
{
|
|
||||||
ENTER("trans=%p", trans);
|
|
||||||
xaccTransDestroy(trans);
|
|
||||||
LEAVE("trans=%p", trans);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
trans_xy(Transaction* trans)
|
|
||||||
{
|
|
||||||
xaccTransDestroy(trans);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
trans_book_end(QofBook* book)
|
|
||||||
{
|
|
||||||
guint old_count = 0;
|
|
||||||
guint count;
|
|
||||||
|
|
||||||
QofCollection *col;
|
|
||||||
col = qof_book_get_collection (book, GNC_ID_TRANS);
|
|
||||||
count = qof_collection_count(col);
|
|
||||||
if( count == 0 ) return;
|
|
||||||
|
|
||||||
printf( "Transactions left: %d\n", count);
|
|
||||||
qof_collection_foreach(col, (QofInstanceForeachCB)trans_destroy, NULL);
|
|
||||||
printf( "Transactions left: %d\n", count);
|
|
||||||
while( old_count != count ) {
|
|
||||||
old_count = count;
|
|
||||||
qof_collection_foreach(col, (QofInstanceForeachCB)trans_destroy, NULL);
|
|
||||||
count = qof_collection_count(col);
|
|
||||||
printf( "Transactions left: %d\n", count);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
/* QofObject function implementation */
|
/* QofObject function implementation */
|
||||||
@ -2085,7 +2024,7 @@ static QofObject trans_object_def = {
|
|||||||
.type_label = "Transaction",
|
.type_label = "Transaction",
|
||||||
.create = (gpointer)xaccMallocTransaction,
|
.create = (gpointer)xaccMallocTransaction,
|
||||||
.book_begin = NULL,
|
.book_begin = NULL,
|
||||||
.book_end = trans_book_end,
|
.book_end = NULL,
|
||||||
.is_dirty = qof_collection_is_dirty,
|
.is_dirty = qof_collection_is_dirty,
|
||||||
.mark_clean = qof_collection_mark_clean,
|
.mark_clean = qof_collection_mark_clean,
|
||||||
.foreach = qof_collection_foreach,
|
.foreach = qof_collection_foreach,
|
||||||
|
@ -602,21 +602,6 @@ gnc_budget_get_default (QofBook *book)
|
|||||||
return bgt;
|
return bgt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Book handling routines */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete all budgets
|
|
||||||
*
|
|
||||||
* @param book Book
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
budget_book_end(QofBook* book)
|
|
||||||
{
|
|
||||||
QofCollection *col;
|
|
||||||
col = qof_book_get_collection(book, GNC_ID_BUDGET);
|
|
||||||
qof_collection_foreach(col, (QofInstanceForeachCB)gnc_budget_destroy, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Define the QofObject. */
|
/* Define the QofObject. */
|
||||||
static QofObject budget_object_def =
|
static QofObject budget_object_def =
|
||||||
{
|
{
|
||||||
@ -625,7 +610,7 @@ static QofObject budget_object_def =
|
|||||||
.type_label = "Budget",
|
.type_label = "Budget",
|
||||||
.create = (gpointer)gnc_budget_new,
|
.create = (gpointer)gnc_budget_new,
|
||||||
.book_begin = NULL,
|
.book_begin = NULL,
|
||||||
.book_end = budget_book_end,
|
.book_end = NULL,
|
||||||
.is_dirty = qof_collection_is_dirty,
|
.is_dirty = qof_collection_is_dirty,
|
||||||
.mark_clean = qof_collection_mark_clean,
|
.mark_clean = qof_collection_mark_clean,
|
||||||
.foreach = qof_collection_foreach,
|
.foreach = qof_collection_foreach,
|
||||||
|
@ -434,34 +434,6 @@ gnc_lot_get_latest_split (GNCLot *lot)
|
|||||||
return node->data;
|
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;
|
|
||||||
guint count;
|
|
||||||
|
|
||||||
col = qof_book_get_collection (book, GNC_ID_LOT);
|
|
||||||
count = qof_collection_count(col);
|
|
||||||
printf( "Book end: Lots left: %d\n", count);
|
|
||||||
while(count > 0) {
|
|
||||||
qof_collection_foreach(col, (QofInstanceForeachCB)lot_destroy_book_end, NULL);
|
|
||||||
count = qof_collection_count(col);
|
|
||||||
printf( "Lots left: %d\n", count);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ============================================================= */
|
/* ============================================================= */
|
||||||
|
|
||||||
static QofObject gncLotDesc =
|
static QofObject gncLotDesc =
|
||||||
@ -471,7 +443,7 @@ static QofObject gncLotDesc =
|
|||||||
.type_label = "Lot",
|
.type_label = "Lot",
|
||||||
.create = (gpointer)gnc_lot_new,
|
.create = (gpointer)gnc_lot_new,
|
||||||
.book_begin = NULL,
|
.book_begin = NULL,
|
||||||
.book_end = lot_book_end,
|
.book_end = NULL,
|
||||||
.is_dirty = qof_collection_is_dirty,
|
.is_dirty = qof_collection_is_dirty,
|
||||||
.mark_clean = qof_collection_mark_clean,
|
.mark_clean = qof_collection_mark_clean,
|
||||||
.foreach = qof_collection_foreach,
|
.foreach = qof_collection_foreach,
|
||||||
|
Loading…
Reference in New Issue
Block a user