mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Create qof_book_begin_edit()/qof_book_commit_edit() routines. These need to be added around lines which set kvp
values for the book, and the dirty flag does *not* need to be set. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18590 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -203,8 +203,12 @@ gnc_get_current_book (void)
|
||||
void
|
||||
gnc_set_current_book_tax_name (const gchar *tax_name)
|
||||
{
|
||||
kvp_frame_set_string (qof_book_get_slots (gnc_get_current_book()),
|
||||
QofBook* current_book = gnc_get_current_book();
|
||||
|
||||
qof_book_begin_edit(current_book);
|
||||
kvp_frame_set_string (qof_book_get_slots (current_book),
|
||||
"book/tax_US/name", tax_name);
|
||||
qof_book_commit_edit(current_book);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
|
||||
@@ -149,8 +149,10 @@ load_single_book( GncSqlBackend* be, GncSqlRow* row )
|
||||
pBook = gnc_book_new();
|
||||
}
|
||||
|
||||
qof_book_begin_edit( pBook );
|
||||
gnc_sql_load_object( be, row, GNC_ID_BOOK, pBook, col_table );
|
||||
gnc_sql_slots_load( be, QOF_INSTANCE(pBook) );
|
||||
qof_book_commit_edit( pBook );
|
||||
|
||||
qof_instance_mark_clean( QOF_INSTANCE(pBook) );
|
||||
}
|
||||
|
||||
@@ -461,6 +461,36 @@ gboolean qof_book_use_trading_accounts (const QofBook *book)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
qof_book_begin_edit (QofBook *book)
|
||||
{
|
||||
qof_begin_edit(&book->inst);
|
||||
}
|
||||
|
||||
static void commit_err (QofInstance *inst, QofBackendError errcode)
|
||||
{
|
||||
PERR ("Failed to commit: %d", errcode);
|
||||
// gnc_engine_signal_commit_error( errcode );
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void lot_free(QofInstance* inst)
|
||||
{
|
||||
GNCLot* lot = GNC_LOT(inst);
|
||||
|
||||
gnc_lot_free(lot);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void noop (QofInstance *inst) {}
|
||||
|
||||
void
|
||||
qof_book_commit_edit(QofBook *book)
|
||||
{
|
||||
if (!qof_commit_edit (QOF_INSTANCE(book))) return;
|
||||
qof_commit_edit_part2 (&book->inst, commit_err, noop, noop/*lot_free*/);
|
||||
}
|
||||
|
||||
/* QofObject function implementation and registration */
|
||||
gboolean qof_book_register (void)
|
||||
{
|
||||
|
||||
@@ -278,6 +278,9 @@ gboolean qof_book_equal (const QofBook *book_1, const QofBook *book_2);
|
||||
*/
|
||||
gint64 qof_book_get_counter (const QofBook *book, const char *counter_name);
|
||||
|
||||
void qof_book_begin_edit(QofBook *book);
|
||||
void qof_book_commit_edit(QofBook *book);
|
||||
|
||||
/** deprecated */
|
||||
#define qof_book_get_guid(X) qof_entity_get_guid (QOF_INSTANCE(X))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user