r19689 - gnucash/trunk/src/import-export/log-replay - Bug 3786338. Change r19243 deleted a call to xaccTransBeginEdit which causes a crash replaying a log that
Mike Alexander
mta at code.gnucash.org
Wed Oct 20 17:31:39 EDT 2010
Author: mta
Date: 2010-10-20 17:31:39 -0400 (Wed, 20 Oct 2010)
New Revision: 19689
Trac: http://svn.gnucash.org/trac/changeset/19689
Modified:
gnucash/trunk/src/import-export/log-replay/gnc-log-replay.c
Log:
Bug 3786338. Change r19243 deleted a call to xaccTransBeginEdit which causes a crash replaying a log that
deletes an existing transaction. Log replay should now do exactly one xaccTransBeginEdit/xaccTransCommitEdit
call per logged transaction.
Modified: gnucash/trunk/src/import-export/log-replay/gnc-log-replay.c
===================================================================
--- gnucash/trunk/src/import-export/log-replay/gnc-log-replay.c 2010-10-20 03:40:07 UTC (rev 19688)
+++ gnucash/trunk/src/import-export/log-replay/gnc-log-replay.c 2010-10-20 21:31:39 UTC (rev 19689)
@@ -396,17 +396,21 @@
if ((trans = xaccTransLookup (&(record.trans_guid), book)) != NULL
&& first_record == TRUE)
{
+ first_record = FALSE;
if (xaccTransGetReadOnly(trans))
{
PWARN("Destroying a read only transaction.");
xaccTransClearReadOnly(trans);
}
+ xaccTransBeginEdit(trans);
xaccTransDestroy(trans);
}
else if (first_record == TRUE)
{
PERR("The transaction to delete was not found!");
}
+ else
+ xaccTransDestroy(trans);
break;
case LOG_COMMIT:
DEBUG("process_trans_record(): Playing back LOG_COMMIT");
@@ -417,6 +421,7 @@
if (trans != NULL)
{
DEBUG("process_trans_record(): Transaction to be edited was found");
+ xaccTransBeginEdit(trans);
trans_ro = g_strdup(xaccTransGetReadOnly(trans));
if (trans_ro)
{
@@ -428,9 +433,9 @@
{
DEBUG("process_trans_record(): Creating a new transaction");
trans = xaccMallocTransaction (book);
+ xaccTransBeginEdit(trans);
}
- xaccTransBeginEdit(trans);
xaccTransSetGUID (trans, &(record.trans_guid));
/*Fill the transaction info*/
if (record.date_entered_present)
@@ -521,8 +526,8 @@
if (trans != NULL) /*If we played with a transaction, commit it here*/
{
xaccTransScrubCurrencyFromSplits(trans);
+ xaccTransSetReadOnly(trans, trans_ro);
xaccTransCommitEdit(trans);
- xaccTransSetReadOnly(trans, trans_ro);
g_free(trans_ro);
}
}
More information about the gnucash-changes
mailing list