gnucash maint: Instrument failure to set the account when creating a split.

John Ralls jralls at code.gnucash.org
Tue Oct 11 17:06:11 EDT 2022


Updated	 via  https://github.com/Gnucash/gnucash/commit/f24c2c8b (commit)
	from  https://github.com/Gnucash/gnucash/commit/2d3e80ea (commit)



commit f24c2c8bdd2d09d12b53654a520714669434d232
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Oct 11 14:05:23 2022 -0700

    Instrument failure to set the  account when creating a split.

diff --git a/libgnucash/backend/sql/gnc-sql-column-table-entry.hpp b/libgnucash/backend/sql/gnc-sql-column-table-entry.hpp
index 7ea6e93c9..926029a38 100644
--- a/libgnucash/backend/sql/gnc-sql-column-table-entry.hpp
+++ b/libgnucash/backend/sql/gnc-sql-column-table-entry.hpp
@@ -187,6 +187,7 @@ public:
                                                  void* pObject, T get_ref)
         const noexcept
         {
+            static QofLogModule log_module = G_LOG_DOMAIN;
             g_return_if_fail (pObject != NULL);
 
             try
@@ -199,9 +200,19 @@ public:
                     if (target != nullptr)
                         set_parameter (pObject, target, get_setter(obj_name),
                                        m_gobj_param_name);
+                    else
+                        DEBUG("GUID %s returned null %s reference.",
+                             val.c_str(), m_gobj_param_name);
                 }
+                else
+                {
+                    if (val.empty()) DEBUG("Can't load empty guid string for column %s", m_col_name);
+                    else DEBUG("Invalid GUID %s for column %s", val.c_str(), m_col_name);
+                }
+            }
+            catch (std::invalid_argument& err) {
+                DEBUG("set_parameter threw %s for column %s", err.what(), m_col_name);
             }
-            catch (std::invalid_argument&) {}
         }
 
 
diff --git a/libgnucash/backend/sql/gnc-transaction-sql.cpp b/libgnucash/backend/sql/gnc-transaction-sql.cpp
index f794f6702..05ad24b7d 100644
--- a/libgnucash/backend/sql/gnc-transaction-sql.cpp
+++ b/libgnucash/backend/sql/gnc-transaction-sql.cpp
@@ -239,6 +239,12 @@ load_single_split (GncSqlBackend* sql_be, GncSqlRow& row)
         qof_backend_set_error ((QofBackend*)sql_be, ERR_BACKEND_DATA_CORRUPT);
         pSplit = NULL;
     }
+    if (!xaccSplitGetAccount(pSplit))
+    {
+        gchar guidstr[GUID_ENCODING_LENGTH + 1];
+        guid_to_string_buff (qof_instance_get_guid (pSplit), guidstr);
+        PERR("Split %s created with no account!", guidstr);
+    }
     return pSplit;
 }
 static void



Summary of changes:
 libgnucash/backend/sql/gnc-sql-column-table-entry.hpp | 13 ++++++++++++-
 libgnucash/backend/sql/gnc-transaction-sql.cpp        |  6 ++++++
 2 files changed, 18 insertions(+), 1 deletion(-)



More information about the gnucash-changes mailing list