From 06db9bcf2b68c9477ea3a75ded16c27597deadd0 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Tue, 17 Apr 2018 23:03:31 +0200 Subject: [PATCH] Fix crash when loading sql book with posted transactions This crash started to appear as of commit 80dbb9940b77d because the sequence of split loading has changed as a result of the query optimizations. Invoice transactions get loaded before the general transaction loading happens. However because of this, when an invoice transaction was encountered again during general transaction loading, it was (correctly) not created again AND (incorrectly) not opened for subsequent editing. This caused an assert to fail when the splits for this transaction are loaded shortly afterwards. The solution is simply to ensure all transactions are opened for editing during the general transaction loading call. --- libgnucash/backend/sql/gnc-transaction-sql.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libgnucash/backend/sql/gnc-transaction-sql.cpp b/libgnucash/backend/sql/gnc-transaction-sql.cpp index 9457a73abc..5aa2310ad8 100644 --- a/libgnucash/backend/sql/gnc-transaction-sql.cpp +++ b/libgnucash/backend/sql/gnc-transaction-sql.cpp @@ -293,9 +293,11 @@ load_single_tx (GncSqlBackend* sql_be, GncSqlRow& row) tx_guid = *guid; // Don't overwrite the transaction if it's already been loaded (and possibly modified). + // However increase the edit level, it may be modified while loading its splits pTx = xaccTransLookup (&tx_guid, sql_be->book()); if (pTx != NULL) { + xaccTransBeginEdit (pTx); return NULL; }