gnucash maint: Bug 795944 - Cannot store change to Business Suppliers data
Geert Janssens
gjanssens at code.gnucash.org
Sat Jun 23 07:25:08 EDT 2018
Updated via https://github.com/Gnucash/gnucash/commit/a438a595 (commit)
from https://github.com/Gnucash/gnucash/commit/92ea3ba8 (commit)
commit a438a59513c703e320189f542b598d84ef21eb41
Author: Geert Janssens <geert at kobaltwit.be>
Date: Sat Jun 23 13:15:38 2018 +0200
Bug 795944 - Cannot store change to Business Suppliers data
The underlying problem was that the vendor object remained in infant state
That confused the backend code so it used an sql INSERT statement instead
of an UPDATE statement to write back the changes. As the object already
existed in the db this would fail.
The fix is to ensure the object doesn't remain in infant state during
sql loading. See the bug report for a more detailed explanation.
diff --git a/libgnucash/backend/sql/gnc-sql-column-table-entry.hpp b/libgnucash/backend/sql/gnc-sql-column-table-entry.hpp
index ce4dfe2..112338b 100644
--- a/libgnucash/backend/sql/gnc-sql-column-table-entry.hpp
+++ b/libgnucash/backend/sql/gnc-sql-column-table-entry.hpp
@@ -544,9 +544,19 @@ void set_parameter(T object, P item, QofSetterFunc setter)
template <typename T, typename P>
void set_parameter(T object, P item, const char* property)
{
- qof_instance_increase_editlevel(object);
+ // Properly use qof_begin_edit and qof_commit_edit{_part2}
+ // here. This is needed to reset the infant state of objects
+ // when loading them initially from sql. Failing to do so
+ // could prevent future editing of these objects
+ // Example of this is https://bugzilla.gnome.org/show_bug.cgi?id=795944
+ qof_begin_edit(QOF_INSTANCE(object));
g_object_set(object, property, item, nullptr);
- qof_instance_decrease_editlevel(object);
+ if (!qof_commit_edit(QOF_INSTANCE(object))) return;
+ // FIXME I can't use object specific callbacks in generic code
+ // so for now these will silently fail. As the GObject based method
+ // of setting qof objects should go away eventually I won't bother
+ // finding a proper solution for this.
+ qof_commit_edit_part2(QOF_INSTANCE(object), nullptr, nullptr, nullptr);
};
/**
Summary of changes:
libgnucash/backend/sql/gnc-sql-column-table-entry.hpp | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
More information about the gnucash-changes
mailing list