From 0aa811489ed60e5f66f152a4cf2d26dc5e7a22a2 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Sat, 7 Oct 2023 09:40:00 +0800 Subject: [PATCH] add qof-session-destroy and qof-session-save-quiet --- bindings/engine.i | 3 +++ libgnucash/engine/qofsession.cpp | 11 +++++++++++ libgnucash/engine/qofsession.h | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/bindings/engine.i b/bindings/engine.i index 7e849af8bbb..cab9ac1a510 100644 --- a/bindings/engine.i +++ b/bindings/engine.i @@ -40,6 +40,7 @@ #include "SX-book.h" #include "gnc-kvp-guile.h" #include "glib-guile.h" +#include "qofsession.h" #include "gncAddress.h" #include "gncBillTerm.h" @@ -200,6 +201,8 @@ QofSession * qof_session_new (QofBook* book); QofBook * qof_session_get_book (QofSession *session); // TODO: Unroll/remove const char *qof_session_get_url (QofSession *session); +void qof_session_destroy (QofSession *session); +void qof_session_save_quiet (QofSession *session); %ignore qof_print_date_time_buff; %ignore gnc_tm_free; diff --git a/libgnucash/engine/qofsession.cpp b/libgnucash/engine/qofsession.cpp index 79b5569fa62..95257e7d90d 100644 --- a/libgnucash/engine/qofsession.cpp +++ b/libgnucash/engine/qofsession.cpp @@ -643,6 +643,17 @@ qof_session_save_in_progress(const QofSession *session) return session->is_saving (); } +static void nop (const char *message, double percent) +{ +} + +void +qof_session_save_quiet (QofSession *session) +{ + if (!session) return; + session->save (nop); +} + void qof_session_end (QofSession *session) { diff --git a/libgnucash/engine/qofsession.h b/libgnucash/engine/qofsession.h index e01d95a6532..2efc339a5b4 100644 --- a/libgnucash/engine/qofsession.h +++ b/libgnucash/engine/qofsession.h @@ -273,6 +273,14 @@ void qof_session_save (QofSession *session, void qof_session_safe_save (QofSession *session, QofPercentageFunc percentage_func); +/** The qof_session_save_quiet () method will commit all changes that have been + * made to the session. For the file backend, this is nothing + * more than a write to the file of the current Accounts & etc. + * For the SQL backend, this is typically a no-op (since all data + * has already been written out to the database. + */ +void qof_session_save_quiet (QofSession *session); + /** * The qof_session_end() method will release the session lock. For the * file backend, it will *not* save the data to a file. Thus,