Bug 799487 - Unable to save gnucash DB file as XML file

Not quite true, it just takes a really long time for a large database.

The underlying problem is gnc_file_do_save_as reloads the data to make
sure that the save-as saves everything. On the SQL backend that
triggers a scrub. The scrub itseld doesn't take long, but every
transaction commit was logged in the transaction log and did a refresh
of the registers. So:
* Suspend logging while doing the scrub.
* Suspend UI refreshes and QOF events while reloading the data.
This commit is contained in:
John Ralls 2024-12-17 16:23:13 -08:00
parent 579eed1fac
commit bda17ff4d8
2 changed files with 8 additions and 1 deletions

View File

@ -1593,8 +1593,12 @@ gnc_file_do_save_as (GtkWindow *parent, const char* filename)
}
/* Make sure all of the data from the old file is loaded */
qof_event_suspend ();
gnc_suspend_gui_refresh ();
qof_session_ensure_all_data_loaded(session);
gnc_resume_gui_refresh ();
qof_event_resume ();
/* -- this session code is NOT identical in FileOpen and FileSaveAs -- */
save_in_progress++;

View File

@ -30,6 +30,7 @@
#include <gncTaxTable.h>
#include <gncInvoice.h>
#include <gnc-pricedb.h>
#include <TransLog.h>
#include <algorithm>
#include <cassert>
@ -347,8 +348,10 @@ GncSqlBackend::load (QofBook* book, QofBackendLoadType loadType)
* m_loading true prevents changes from being written back to the
* database. Do that now.
*/
xaccLogDisable();
auto transactions = qof_book_get_collection (book, GNC_ID_TRANS);
qof_collection_foreach(transactions, scrub_txn_callback, nullptr);
xaccLogEnable();
/* Mark the session as clean -- though it should never be marked
* dirty with this backend