mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Make backend sync errors survive to the session.
The backends were using qof_backend_get_error() to test for sync errors. This function clears the error, so the tests resulted in the error being cleared before the session could see it and so it thought that the sync had succeeded. Replace those uses of qof_backend_get_error() with a new function qof_backend_check_error() that doesn't clear the error.
This commit is contained in:
parent
d2798b8c3f
commit
3ccaec6e38
@ -1685,7 +1685,7 @@ gnc_dbi_safe_sync_all( QofBackend *qbe, QofBook *book )
|
||||
be->primary_book = book;
|
||||
|
||||
gnc_sql_sync_all( &be->sql_be, book );
|
||||
if ( ERR_BACKEND_NO_ERR != qof_backend_get_error( qbe ) )
|
||||
if (qof_backend_check_error (qbe))
|
||||
{
|
||||
conn_table_operation( (GncSqlConnection*)conn, table_list,
|
||||
rollback );
|
||||
|
@ -512,6 +512,7 @@ gnc_sql_sync_all( GncSqlBackend* be, /*@ dependent @*/ QofBook *book )
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!qof_backend_check_error ((QofBackend*)be))
|
||||
qof_backend_set_error( (QofBackend*)be, ERR_BACKEND_SERVER_ERR );
|
||||
is_ok = gnc_sql_connection_rollback_transaction( be->conn );
|
||||
}
|
||||
|
@ -1670,8 +1670,7 @@ gnc_book_write_accounts_to_xml_file_v2(
|
||||
if (out && fclose(out))
|
||||
success = FALSE;
|
||||
|
||||
if (!success
|
||||
&& qof_backend_get_error(be) == ERR_BACKEND_NO_ERR)
|
||||
if (!success && !qof_backend_check_error(be))
|
||||
{
|
||||
|
||||
/* Use a generic write error code */
|
||||
@ -2186,4 +2185,3 @@ gnc_xml2_parse_with_subst (FileBackend *fbe, QofBook *book, GHashTable *subst)
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
@ -64,6 +64,13 @@ qof_backend_get_error (QofBackend *be)
|
||||
return err;
|
||||
}
|
||||
|
||||
gboolean
|
||||
qof_backend_check_error (QofBackend *be)
|
||||
{
|
||||
g_return_val_if_fail (be != NULL, TRUE);
|
||||
return be->last_err != ERR_BACKEND_NO_ERR;
|
||||
}
|
||||
|
||||
void
|
||||
qof_backend_set_message (QofBackend *be, const char *format, ...)
|
||||
{
|
||||
|
@ -166,6 +166,14 @@ void qof_backend_set_error (QofBackend *be, QofBackendError err);
|
||||
*/
|
||||
QofBackendError qof_backend_get_error (QofBackend *be);
|
||||
|
||||
/** Report if the backend is in an error state.
|
||||
* Since get_error resets the error state, its use for branching as the backend
|
||||
* bubbles back up to the session would make the session think that there was
|
||||
* no error.
|
||||
* \param be The backend being tested.
|
||||
* \return TRUE if the backend has an error set.
|
||||
*/
|
||||
gboolean qof_backend_check_error (QofBackend *be);
|
||||
|
||||
/** \brief Load a QOF-compatible backend shared library.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user