Bug 797983 - v4.2 report numbers change over gnucash restarts;...

Price Database dropping user:price-editor entries.

A wider problem: QofInstance was unmarking itself dirty as long as the
backend raised an error and unconditionally marking itself non-infant.

This matters because the SQL backend depends on infant status to decide
whether to do an insert or update query; either will fail if the infant
status is wrong.

The price editor dialog clones a price having only its commodity set and
GncSqlPriceBackend declines to save if the currency isn't set. Since the
instance marked itself non-infant even though it wasn't saved subsequent
commits tried to use an update query and since the price wasn't in the
table that inevitably failed.

Requiring that QofBackend::commit should doing the marking-clean
required implementing it in the backends where it wasn't already.
This commit is contained in:
John Ralls
2020-10-18 15:04:06 -07:00
parent e255a7bfe2
commit 94a68dca7c
6 changed files with 25 additions and 6 deletions

View File

@@ -314,6 +314,13 @@ GncXmlBackend::sync(QofBook* book)
remove_old_files();
}
void
GncXmlBackend::commit(QofInstance* instance)
{
if (qof_instance_is_dirty(instance))
qof_instance_mark_clean(instance);
}
bool
GncXmlBackend::save_may_clobber_data()
{

View File

@@ -43,6 +43,7 @@ public:
void export_coa(QofBook*) override;
void sync(QofBook* book) override;
void safe_sync(QofBook* book) override { sync(book); } // XML sync is inherently safe.
void commit(QofInstance* instance) override;
const char * get_filename() { return m_fullpath.c_str(); }
QofBook* get_book() { return m_book; }