gnucash unstable: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Fri Oct 27 12:56:27 EDT 2017
Updated via https://github.com/Gnucash/gnucash/commit/04642fc4 (commit)
via https://github.com/Gnucash/gnucash/commit/d17c24b7 (commit)
from https://github.com/Gnucash/gnucash/commit/77ab0410 (commit)
commit 04642fc42a4c8cd748ce973a8883a5097540722d
Author: John Ralls <jralls at ceridwen.us>
Date: Fri Oct 27 09:39:02 2017 -0700
[SQL] Check return of string_to_guid, bail if false.
diff --git a/libgnucash/backend/sql/gnc-owner-sql.cpp b/libgnucash/backend/sql/gnc-owner-sql.cpp
index 443ab1a..2587689 100644
--- a/libgnucash/backend/sql/gnc-owner-sql.cpp
+++ b/libgnucash/backend/sql/gnc-owner-sql.cpp
@@ -58,10 +58,10 @@ GncSqlColumnTableEntryImpl<CT_OWNERREF>::load (const GncSqlBackend* sql_be,
GncOwnerType type;
GncGUID guid;
GncOwner owner;
- GncGUID* pGuid = NULL;
+ GncGUID* pGuid = nullptr;
- g_return_if_fail (sql_be != NULL);
- g_return_if_fail (pObject != NULL);
+ g_return_if_fail (sql_be != nullptr);
+ g_return_if_fail (pObject != nullptr);
auto book = sql_be->book();
auto buf = std::string{m_col_name} + "_type";
@@ -70,14 +70,16 @@ GncSqlColumnTableEntryImpl<CT_OWNERREF>::load (const GncSqlBackend* sql_be,
type = static_cast<decltype(type)>(row.get_int_at_col (buf.c_str()));
buf = std::string{m_col_name} + "_guid";
auto val = row.get_string_at_col (buf.c_str());
- string_to_guid (val.c_str(), &guid);
- pGuid = &guid;
+ if (string_to_guid (val.c_str(), &guid))
+ pGuid = &guid;
}
catch (std::invalid_argument)
{
return;
}
-
+ if (type == GNC_OWNER_NONE || pGuid == nullptr)
+ return;
+
switch (type)
{
case GNC_OWNER_CUSTOMER:
diff --git a/libgnucash/backend/sql/gnc-slots-sql.cpp b/libgnucash/backend/sql/gnc-slots-sql.cpp
index 2e8cee7..79cc038 100644
--- a/libgnucash/backend/sql/gnc-slots-sql.cpp
+++ b/libgnucash/backend/sql/gnc-slots-sql.cpp
@@ -711,8 +711,8 @@ gnc_sql_slots_delete (GncSqlBackend* sql_be, const GncGUID* guid)
col_table[guid_val_col];
GncGUID child_guid;
auto val = row.get_string_at_col (table_row->name());
- (void)string_to_guid (val.c_str(), &child_guid);
- gnc_sql_slots_delete (sql_be, &child_guid);
+ if (string_to_guid (val.c_str(), &child_guid))
+ gnc_sql_slots_delete (sql_be, &child_guid);
}
catch (std::invalid_argument)
{
diff --git a/libgnucash/backend/sql/gnc-sql-column-table-entry.cpp b/libgnucash/backend/sql/gnc-sql-column-table-entry.cpp
index 7b5d9bc..3f3bf52 100644
--- a/libgnucash/backend/sql/gnc-sql-column-table-entry.cpp
+++ b/libgnucash/backend/sql/gnc-sql-column-table-entry.cpp
@@ -338,8 +338,8 @@ GncSqlColumnTableEntryImpl<CT_GUID>::load (const GncSqlBackend* sql_be,
{
return;
}
- (void)string_to_guid (str.c_str(), &guid);
- set_parameter(pObject, &guid, get_setter(obj_name), m_gobj_param_name);
+ if (string_to_guid (str.c_str(), &guid))
+ set_parameter(pObject, &guid, get_setter(obj_name), m_gobj_param_name);
}
template<> void
diff --git a/libgnucash/backend/sql/gnc-sql-column-table-entry.hpp b/libgnucash/backend/sql/gnc-sql-column-table-entry.hpp
index 887d457..d86fbfc 100644
--- a/libgnucash/backend/sql/gnc-sql-column-table-entry.hpp
+++ b/libgnucash/backend/sql/gnc-sql-column-table-entry.hpp
@@ -168,11 +168,13 @@ public:
{
GncGUID guid;
auto val = row.get_string_at_col (m_col_name);
- (void)string_to_guid (val.c_str(), &guid);
- auto target = get_ref(&guid);
- if (target != nullptr)
- set_parameter (pObject, target, get_setter(obj_name),
- m_gobj_param_name);
+ if (string_to_guid (val.c_str(), &guid))
+ {
+ auto target = get_ref(&guid);
+ if (target != nullptr)
+ set_parameter (pObject, target, get_setter(obj_name),
+ m_gobj_param_name);
+ }
}
catch (std::invalid_argument) {}
}
diff --git a/libgnucash/backend/sql/gnc-transaction-sql.cpp b/libgnucash/backend/sql/gnc-transaction-sql.cpp
index c5627a8..5fc8a43 100644
--- a/libgnucash/backend/sql/gnc-transaction-sql.cpp
+++ b/libgnucash/backend/sql/gnc-transaction-sql.cpp
@@ -1308,8 +1308,9 @@ GncSqlColumnTableEntryImpl<CT_TXREF>::load (const GncSqlBackend* sql_be,
{
auto val = row.get_string_at_col (m_col_name);
GncGUID guid;
- (void)string_to_guid (val.c_str(), &guid);
- auto tx = xaccTransLookup (&guid, sql_be->book());
+ Transaction *tx = nullptr;
+ if (string_to_guid (val.c_str(), &guid))
+ tx = xaccTransLookup (&guid, sql_be->book());
// If the transaction is not found, try loading it
if (tx == nullptr)
commit d17c24b77098159093a04c554b0760ac6a380812
Author: John Ralls <jralls at ceridwen.us>
Date: Thu Oct 26 15:34:14 2017 -0700
Bug 789298 - Prompt for file history update leads to crash during startup.
diff --git a/libgnucash/backend/sql/gnc-bill-term-sql.cpp b/libgnucash/backend/sql/gnc-bill-term-sql.cpp
index f7c316e..8d77b94 100644
--- a/libgnucash/backend/sql/gnc-bill-term-sql.cpp
+++ b/libgnucash/backend/sql/gnc-bill-term-sql.cpp
@@ -98,7 +98,7 @@ static EntryVec col_table
static EntryVec billterm_parent_col_table
{
- gnc_sql_make_table_entry<CT_INT64>("parent", 0, 0, nullptr,
+ gnc_sql_make_table_entry<CT_GUID>("parent", 0, 0, nullptr,
bt_set_parent_guid),
};
@@ -212,7 +212,7 @@ load_single_billterm (GncSqlBackend* sql_be, GncSqlRow& row,
s.billterm = pBillTerm;
s.have_guid = false;
- gnc_sql_load_object (sql_be, row, GNC_ID_TAXTABLE, &s,
+ gnc_sql_load_object (sql_be, row, GNC_ID_BILLTERM, &s,
billterm_parent_col_table);
if (s.have_guid)
l_billterms_needing_parents.push_back(new BillTermParentGuid(s));
diff --git a/libgnucash/backend/sql/gnc-owner-sql.cpp b/libgnucash/backend/sql/gnc-owner-sql.cpp
index 25ebf71..443ab1a 100644
--- a/libgnucash/backend/sql/gnc-owner-sql.cpp
+++ b/libgnucash/backend/sql/gnc-owner-sql.cpp
@@ -226,7 +226,7 @@ GncSqlColumnTableEntryImpl<CT_OWNERREF>::add_to_query(QofIdTypeConst obj_name,
buf.str("");
auto guid = qof_instance_get_guid(inst);
if (guid != nullptr)
- buf << guid;
+ buf << guid_to_string(guid);
else
buf << "NULL";
vec.emplace_back(std::make_pair(guid_hdr, buf.str()));
diff --git a/libgnucash/backend/sql/gnc-slots-sql.cpp b/libgnucash/backend/sql/gnc-slots-sql.cpp
index 694d453..2e8cee7 100644
--- a/libgnucash/backend/sql/gnc-slots-sql.cpp
+++ b/libgnucash/backend/sql/gnc-slots-sql.cpp
@@ -889,7 +889,7 @@ load_slot_for_book_object (GncSqlBackend* sql_be, GncSqlRow& row,
guid = load_obj_guid (sql_be, row);
g_return_if_fail (guid != NULL);
inst = lookup_fn (guid, sql_be->book());
- g_return_if_fail (inst != NULL);
+ if (inst == NULL) return; /* Silently bail if the guid isn't loaded yet. */
slot_info.be = sql_be;
slot_info.pKvpFrame = qof_instance_get_slots (inst);
Summary of changes:
libgnucash/backend/sql/gnc-bill-term-sql.cpp | 4 ++--
libgnucash/backend/sql/gnc-owner-sql.cpp | 16 +++++++++-------
libgnucash/backend/sql/gnc-slots-sql.cpp | 6 +++---
libgnucash/backend/sql/gnc-sql-column-table-entry.cpp | 4 ++--
libgnucash/backend/sql/gnc-sql-column-table-entry.hpp | 12 +++++++-----
libgnucash/backend/sql/gnc-transaction-sql.cpp | 5 +++--
6 files changed, 26 insertions(+), 21 deletions(-)
More information about the gnucash-changes
mailing list