gnucash master: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Sun May 31 10:04:43 EDT 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/658241d3 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/fe09c45d (commit)
	from  https://github.com/Gnucash/gnucash/commit/2a42078e (commit)



commit 658241d3bec97fd41828ed522a976775d8c7ddc9
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun May 31 21:29:47 2020 +0800

    [gnucash-commands] don't force open a locked datafile
    
    qof_session_begin (..., ..., ignore_lock=TRUE, ..., ...) will
    force-open a datafile currently in use in another session.
    
    This will unfortunately delete any existing .LCK file.
    
    To my knowledge there is no read-only qofsession which will leave .LCK
    file intact. Therefore to prevent possible dataloss, it is best to
    disallow opening a locked file which prevents deletion of .LCK file.

diff --git a/gnucash/gnucash-commands.cpp b/gnucash/gnucash-commands.cpp
index 638c4c25a..2b6dd2f3d 100644
--- a/gnucash/gnucash-commands.cpp
+++ b/gnucash/gnucash-commands.cpp
@@ -168,9 +168,12 @@ scm_run_report (void *data,
     if (!session)
         scm_cleanup_and_exit_with_failure (session);
 
-    qof_session_begin (session, datafile, TRUE, FALSE, FALSE);
+    qof_session_begin (session, datafile, FALSE, FALSE, FALSE);
     if (qof_session_get_error (session) != ERR_BACKEND_NO_ERR)
+    {
+        fprintf (stderr, "ERROR: datafile not found, or locked in another session\n");
         scm_cleanup_and_exit_with_failure (session);
+    }
 
     qof_session_load (session, report_session_percentage);
     if (qof_session_get_error (session) != ERR_BACKEND_NO_ERR)

commit fe09c45d1796b6ef9b767534903b2ddc6d18f363
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun May 31 21:43:17 2020 +0800

    [gnucash-commands] fprintf instead of g_warning
    
    because g_warning doesn't actually report error. also fix indent which
    was previously misleading.

diff --git a/gnucash/gnucash-commands.cpp b/gnucash/gnucash-commands.cpp
index 029ede5e7..638c4c25a 100644
--- a/gnucash/gnucash-commands.cpp
+++ b/gnucash/gnucash-commands.cpp
@@ -54,9 +54,9 @@ scm_cleanup_and_exit_with_failure (QofSession *session)
     if (session)
     {
         if (qof_session_get_error (session) != ERR_BACKEND_NO_ERR)
-            g_warning ("Session Error: %s",
-                       qof_session_get_error_message (session));
-            qof_session_destroy (session);
+            fprintf (stderr, "Session Error: %s\n",
+                     qof_session_get_error_message (session));
+        qof_session_destroy (session);
     }
     qof_event_resume();
     gnc_shutdown (1);
@@ -106,7 +106,7 @@ scm_add_quotes(void *data, [[maybe_unused]] int argc, [[maybe_unused]] char **ar
     qof_session_destroy(session);
     if (!scm_is_true(scm_result))
     {
-        g_warning("Failed to add quotes to %s.", add_quotes_file->c_str());
+        fprintf (stderr, "Failed to add quotes to %s.", add_quotes_file->c_str());
         scm_cleanup_and_exit_with_failure (session);
     }
 



Summary of changes:
 gnucash/gnucash-commands.cpp | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)



More information about the gnucash-changes mailing list