diff --git a/libgnucash/backend/sql/gnc-transaction-sql.cpp b/libgnucash/backend/sql/gnc-transaction-sql.cpp index f2e2b1fc5f..df1c95090b 100644 --- a/libgnucash/backend/sql/gnc-transaction-sql.cpp +++ b/libgnucash/backend/sql/gnc-transaction-sql.cpp @@ -225,16 +225,11 @@ load_single_split (GncSqlBackend* sql_be, GncSqlRow& row) pSplit = xaccSplitLookup (&split_guid, sql_be->book()); } - if (pSplit == NULL) - { - pSplit = xaccMallocSplit (sql_be->book()); - } + if (pSplit) + return pSplit; //Already loaded, nothing to do. - /* If the split is dirty, don't overwrite it */ - if (!qof_instance_is_dirty (QOF_INSTANCE (pSplit))) - { - gnc_sql_load_object (sql_be, row, GNC_ID_SPLIT, pSplit, split_col_table); - } + pSplit = xaccMallocSplit (sql_be->book()); + gnc_sql_load_object (sql_be, row, GNC_ID_SPLIT, pSplit, split_col_table); /*# -ifempty */ if (pSplit != xaccSplitLookup (&split_guid, sql_be->book())) @@ -272,7 +267,7 @@ load_splits_for_transactions (GncSqlBackend* sql_be, std::string selector) auto result = sql_be->execute_select_statement (stmt); for (auto row : *result) - Split* s = load_single_split (sql_be, row); + load_single_split (sql_be, row); sql = "SELECT DISTINCT "; sql += spkey + " FROM " SPLIT_TABLE " WHERE " + sskey + " IN " + selector; gnc_sql_slots_load_for_sql_subquery(sql_be, sql, @@ -292,14 +287,9 @@ load_single_tx (GncSqlBackend* sql_be, GncSqlRow& row) if (guid == NULL) return NULL; 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; - } + if (pTx) + return nullptr; // Nothing to do. pTx = xaccMallocTransaction (sql_be->book()); xaccTransBeginEdit (pTx);