gboolean qof_commit_edit_part2(QofInstance *inst, void (*on_error)(QofInstance *, QofBackendError), void (*on_done)(QofInstance *), void (*on_free)(QofInstance *)) { QofInstancePrivate *priv; QofBackend * be; priv = GET_PRIVATE(inst); if (priv->dirty && !(priv->infant && priv->do_free)) { qof_collection_mark_dirty(priv->collection); qof_book_mark_session_dirty(priv->book); } /* See if there's a backend. If there is, invoke it. */ be = qof_book_get_backend(priv->book); if (be && qof_backend_commit_exists(be)) { QofBackendError errcode; /* clear errors */ do { errcode = qof_backend_get_error(be); } while (ERR_BACKEND_NO_ERR != errcode); qof_backend_run_commit(be, inst); errcode = qof_backend_get_error(be); if (ERR_BACKEND_NO_ERR != errcode) { /* XXX Should perform a rollback here */ priv->do_free = FALSE; /* Push error back onto the stack */ qof_backend_set_error (be, errcode); if (on_error) on_error(inst, errcode); return FALSE; } /* XXX the backend commit code should clear dirty!! */ priv->dirty = FALSE; } priv->infant = FALSE; if (priv->do_free) { if (on_free) on_free(inst); return TRUE; } if (on_done) on_done(inst); return TRUE; }
void qof_instance_set_dirty(QofInstance* inst) { QofInstancePrivate *priv; QofCollection *coll; priv = GET_PRIVATE(inst); priv->dirty = TRUE; if (!qof_get_alt_dirty_mode()) { coll = priv->collection; qof_collection_mark_dirty(coll); } }