mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-21 16:38:06 -06:00
Bug 798789 - Trading Accounts
Scrubbing during SQL load can't commit the changes from the scrub because the backend's m_loading member is true so disable scrubbing during database load and edit/commit all transactions again after loading is complete.
This commit is contained in:
parent
292adf69d8
commit
7f8d5456c7
@ -271,6 +271,13 @@ typedef struct
|
||||
gnc_sql_query_info* pQueryInfo;
|
||||
} sql_backend;
|
||||
|
||||
static void
|
||||
scrub_txn_callback (QofInstance* inst, [[maybe_unused]] void* data)
|
||||
{
|
||||
auto trans = GNC_TRANSACTION(inst);
|
||||
xaccTransBeginEdit(trans);
|
||||
xaccTransCommitEdit(trans);
|
||||
}
|
||||
|
||||
void
|
||||
GncSqlBackend::load (QofBook* book, QofBackendLoadType loadType)
|
||||
@ -336,6 +343,12 @@ GncSqlBackend::load (QofBook* book, QofBackendLoadType loadType)
|
||||
gnc_commodity_commit_edit(comm);
|
||||
});
|
||||
m_postload_commodities.clear();
|
||||
/* We deferred the transaction scrub while loading because having
|
||||
* m_loading true prevents changes from being written back to the
|
||||
* database. Do that now.
|
||||
*/
|
||||
auto transactions = qof_book_get_collection (book, GNC_ID_TRANS);
|
||||
qof_collection_foreach(transactions, scrub_txn_callback, nullptr);
|
||||
|
||||
/* Mark the session as clean -- though it should never be marked
|
||||
* dirty with this backend
|
||||
|
@ -36,6 +36,7 @@
|
||||
|
||||
#include "Account.h"
|
||||
#include "Transaction.h"
|
||||
#include <TransactionP.hpp>
|
||||
#include <Scrub.h>
|
||||
#include "gnc-lot.h"
|
||||
#include "engine-helpers.h"
|
||||
@ -389,10 +390,12 @@ query_transactions (GncSqlBackend* sql_be, std::string selector)
|
||||
(BookLookupFn)xaccTransLookup);
|
||||
}
|
||||
|
||||
// Commit all of the transactions
|
||||
// Commit all of the transactions, but don't scrub because any
|
||||
// scrubbing changes won't be written back to the database
|
||||
xaccDisableDataScrubbing();
|
||||
for (auto instance : instances)
|
||||
xaccTransCommitEdit(GNC_TRANSACTION(instance));
|
||||
|
||||
xaccEnableDataScrubbing();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user