Skip to content

Commit

Permalink
Bug 799487 - Unable to save gnucash DB file as XML file
Browse files Browse the repository at this point in the history
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 while reloading the data.
* Make the register page event handler obey the refresh being suspended.
  • Loading branch information
jralls committed Dec 18, 2024
1 parent a716cca commit 71ff12b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions gnucash/gnome-utils/gnc-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1593,7 +1593,9 @@ gnc_file_do_save_as (GtkWindow *parent, const char* filename)
}

/* Make sure all of the data from the old file is loaded */
gnc_suspend_gui_refresh ();
qof_session_ensure_all_data_loaded(session);
gnc_resume_gui_refresh ();

/* -- this session code is NOT identical in FileOpen and FileSaveAs -- */

Expand Down
6 changes: 6 additions & 0 deletions gnucash/gnome/gnc-plugin-page-register.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5329,6 +5329,12 @@ gnc_plugin_page_register_event_handler (QofInstance* entity,
ENTER ("entity %p of type %d, page %p, event data %p",
entity, event_type, page, ed);

if (gnc_gui_refresh_suspended ())
{
LEAVE("Gui Refresh Suspended.");
return;
}

window = gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page));

if (GNC_IS_ACCOUNT (entity))
Expand Down
3 changes: 3 additions & 0 deletions libgnucash/backend/sql/gnc-sql-backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <gncTaxTable.h>
#include <gncInvoice.h>
#include <gnc-pricedb.h>
#include <TransLog.h>

#include <algorithm>
#include <cassert>
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 71ff12b

Please sign in to comment.