Bug 796248 - Editing Scheduled Transaction, take 2.

In addition to not begining to edit already-loaded transactions,
don't try to load splits that are already loaded. It shouldn't
be possible to load a transaction without also loading its splits.
This commit is contained in:
John Ralls 2018-06-26 15:04:23 -07:00
parent 4e04f6e51d
commit f7ed46a35b

View File

@ -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);