mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Merge branch 'maint'
This commit is contained in:
commit
1df569e98c
@ -99,6 +99,8 @@ static GncSqlStatement* build_delete_statement( GncSqlBackend* be,
|
||||
QofIdTypeConst obj_name, gpointer pObject,
|
||||
const GncSqlColumnTableEntry* table );
|
||||
|
||||
static GList *post_load_commodities = NULL;
|
||||
|
||||
#define TRANSACTION_NAME "trans"
|
||||
|
||||
typedef struct
|
||||
@ -208,6 +210,20 @@ initial_load_cb( const gchar* type, gpointer data_p, gpointer be_p )
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gnc_sql_push_commodity_for_postload_processing (GncSqlBackend *be,
|
||||
gpointer *comm)
|
||||
{
|
||||
post_load_commodities = g_list_prepend(post_load_commodities, comm);
|
||||
}
|
||||
|
||||
static void
|
||||
commit_commodity (gpointer data)
|
||||
{
|
||||
gnc_commodity *comm = GNC_COMMODITY (data);
|
||||
gnc_sql_commit_commodity (comm);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_sql_load( GncSqlBackend* be, /*@ dependent @*/ QofBook *book, QofBackendLoadType loadType )
|
||||
{
|
||||
@ -264,6 +280,8 @@ gnc_sql_load( GncSqlBackend* be, /*@ dependent @*/ QofBook *book, QofBackendLoad
|
||||
}
|
||||
|
||||
be->loading = FALSE;
|
||||
g_list_free_full (post_load_commodities, commit_commodity);
|
||||
post_load_commodities = NULL;
|
||||
|
||||
/* Mark the sessoion as clean -- though it should never be marked
|
||||
* dirty with this backend
|
||||
|
@ -81,6 +81,16 @@ void gnc_sql_init( GncSqlBackend* be );
|
||||
*/
|
||||
void gnc_sql_load( GncSqlBackend* be, /*@ dependent @*/ QofBook *book, QofBackendLoadType loadType );
|
||||
|
||||
/**
|
||||
* Register a commodity to be committed after loading is complete.
|
||||
*
|
||||
* Necessary to save corrections made while loading.
|
||||
* @param be SQL backend
|
||||
* @param comm The commodity item to be committed.
|
||||
*/
|
||||
void gnc_sql_push_commodity_for_postload_processing (GncSqlBackend *be,
|
||||
gpointer *comm);
|
||||
|
||||
/**
|
||||
* Save the contents of a book to an SQL database.
|
||||
*
|
||||
|
@ -154,6 +154,8 @@ load_all_commodities( GncSqlBackend* be )
|
||||
|
||||
guid = *qof_instance_get_guid( QOF_INSTANCE(pCommodity) );
|
||||
pCommodity = gnc_commodity_table_insert( pTable, pCommodity );
|
||||
if (qof_instance_is_dirty (QOF_INSTANCE (pCommodity)))
|
||||
gnc_sql_push_commodity_for_postload_processing (be, (gpointer)pCommodity);
|
||||
qof_instance_set_guid( QOF_INSTANCE(pCommodity), &guid );
|
||||
}
|
||||
row = gnc_sql_result_get_next_row( result );
|
||||
@ -258,6 +260,15 @@ gnc_sql_save_commodity( GncSqlBackend* be, gnc_commodity* pCommodity )
|
||||
return is_ok;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_sql_commit_commodity (gnc_commodity *pCommodity)
|
||||
{
|
||||
g_return_if_fail (pCommodity != NULL);
|
||||
g_return_if_fail (GNC_IS_COMMODITY (pCommodity));
|
||||
gnc_commodity_begin_edit (pCommodity);
|
||||
gnc_commodity_commit_edit (pCommodity);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
|
@ -34,5 +34,6 @@
|
||||
|
||||
void gnc_sql_init_commodity_handler( void );
|
||||
gboolean gnc_sql_save_commodity( GncSqlBackend* be, gnc_commodity* pCommodity );
|
||||
void gnc_sql_commit_commodity (gnc_commodity* pCommodity);
|
||||
|
||||
#endif /* GNC_COMMODITY_SQL_H */
|
||||
|
@ -856,6 +856,7 @@ gnc_commodity_new(QofBook *book, const char * fullname,
|
||||
gnc_commodity_set_mnemonic(retval, mnemonic);
|
||||
gnc_commodity_set_cusip(retval, cusip);
|
||||
gnc_commodity_set_fraction(retval, fraction);
|
||||
mark_commodity_dirty (retval);
|
||||
gnc_commodity_commit_edit(retval);
|
||||
|
||||
qof_event_gen (&retval->inst, QOF_EVENT_CREATE, NULL);
|
||||
@ -1925,6 +1926,7 @@ gnc_commodity_table_insert(gnc_commodity_table * table,
|
||||
"namespace User", priv->mnemonic);
|
||||
gnc_commodity_set_namespace (comm, "User");
|
||||
ns_name = "User";
|
||||
mark_commodity_dirty (comm);
|
||||
}
|
||||
|
||||
book = qof_instance_get_book (&comm->inst);
|
||||
|
Loading…
Reference in New Issue
Block a user