mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug #637770: Fix progress bar on load and full save in sql backend.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20156 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
d4e3354c47
commit
ce8997dc45
@ -83,7 +83,8 @@
|
|||||||
static const gchar* convert_search_obj( QofIdType objType );
|
static const gchar* convert_search_obj( QofIdType objType );
|
||||||
#endif
|
#endif
|
||||||
static void gnc_sql_init_object_handlers( void );
|
static void gnc_sql_init_object_handlers( void );
|
||||||
static void update_save_progress( GncSqlBackend* be );
|
static void update_progress( GncSqlBackend* be );
|
||||||
|
static void finish_progress( GncSqlBackend* be );
|
||||||
static void register_standard_col_type_handlers( void );
|
static void register_standard_col_type_handlers( void );
|
||||||
static gboolean reset_version_info( GncSqlBackend* be );
|
static gboolean reset_version_info( GncSqlBackend* be );
|
||||||
/*@ null @*/
|
/*@ null @*/
|
||||||
@ -160,6 +161,7 @@ create_tables_cb( const gchar* type, gpointer data_p, gpointer be_p )
|
|||||||
|
|
||||||
if ( pData->create_tables != NULL )
|
if ( pData->create_tables != NULL )
|
||||||
{
|
{
|
||||||
|
update_progress( be );
|
||||||
(pData->create_tables)( be );
|
(pData->create_tables)( be );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -192,12 +194,14 @@ initial_load_cb( const gchar* type, gpointer data_p, gpointer be_p )
|
|||||||
// Don't need to load anything if it has already been loaded with the fixed order
|
// Don't need to load anything if it has already been loaded with the fixed order
|
||||||
for ( i = 0; fixed_load_order[i] != NULL; i++ )
|
for ( i = 0; fixed_load_order[i] != NULL; i++ )
|
||||||
{
|
{
|
||||||
|
update_progress( be );
|
||||||
if ( g_ascii_strcasecmp( type, fixed_load_order[i] ) == 0 ) return;
|
if ( g_ascii_strcasecmp( type, fixed_load_order[i] ) == 0 ) return;
|
||||||
}
|
}
|
||||||
if ( other_load_order != NULL )
|
if ( other_load_order != NULL )
|
||||||
{
|
{
|
||||||
for ( i = 0; other_load_order[i] != NULL; i++ )
|
for ( i = 0; other_load_order[i] != NULL; i++ )
|
||||||
{
|
{
|
||||||
|
update_progress( be );
|
||||||
if ( g_ascii_strcasecmp( type, other_load_order[i] ) == 0 ) return;
|
if ( g_ascii_strcasecmp( type, other_load_order[i] ) == 0 ) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -233,6 +237,7 @@ gnc_sql_load( GncSqlBackend* be, /*@ dependent @*/ QofBook *book, QofBackendLoad
|
|||||||
pData = qof_object_lookup_backend( fixed_load_order[i], GNC_SQL_BACKEND );
|
pData = qof_object_lookup_backend( fixed_load_order[i], GNC_SQL_BACKEND );
|
||||||
if ( pData->initial_load != NULL )
|
if ( pData->initial_load != NULL )
|
||||||
{
|
{
|
||||||
|
update_progress( be );
|
||||||
(pData->initial_load)( be );
|
(pData->initial_load)( be );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -243,6 +248,7 @@ gnc_sql_load( GncSqlBackend* be, /*@ dependent @*/ QofBook *book, QofBackendLoad
|
|||||||
pData = qof_object_lookup_backend( other_load_order[i], GNC_SQL_BACKEND );
|
pData = qof_object_lookup_backend( other_load_order[i], GNC_SQL_BACKEND );
|
||||||
if ( pData->initial_load != NULL )
|
if ( pData->initial_load != NULL )
|
||||||
{
|
{
|
||||||
|
update_progress( be );
|
||||||
(pData->initial_load)( be );
|
(pData->initial_load)( be );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -265,6 +271,7 @@ gnc_sql_load( GncSqlBackend* be, /*@ dependent @*/ QofBook *book, QofBackendLoad
|
|||||||
|
|
||||||
// Mark the book as clean
|
// Mark the book as clean
|
||||||
qof_book_mark_saved( book );
|
qof_book_mark_saved( book );
|
||||||
|
finish_progress( be );
|
||||||
|
|
||||||
LEAVE( "" );
|
LEAVE( "" );
|
||||||
}
|
}
|
||||||
@ -320,6 +327,7 @@ write_commodities( GncSqlBackend* be, QofBook* book )
|
|||||||
gnc_sql_save_commodity( be, GNC_COMMODITY(lp2->data) );
|
gnc_sql_save_commodity( be, GNC_COMMODITY(lp2->data) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
update_progress( be );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -342,10 +350,10 @@ write_account_tree( GncSqlBackend* be, Account* root )
|
|||||||
{
|
{
|
||||||
is_ok = gnc_sql_save_account( be, QOF_INSTANCE(GNC_ACCOUNT(node->data)) );
|
is_ok = gnc_sql_save_account( be, QOF_INSTANCE(GNC_ACCOUNT(node->data)) );
|
||||||
if ( !is_ok ) break;
|
if ( !is_ok ) break;
|
||||||
update_save_progress( be );
|
}
|
||||||
}
|
|
||||||
g_list_free( descendants );
|
g_list_free( descendants );
|
||||||
}
|
}
|
||||||
|
update_progress( be );
|
||||||
|
|
||||||
return is_ok;
|
return is_ok;
|
||||||
}
|
}
|
||||||
@ -357,9 +365,11 @@ write_accounts( GncSqlBackend* be )
|
|||||||
|
|
||||||
g_return_val_if_fail( be != NULL, FALSE );
|
g_return_val_if_fail( be != NULL, FALSE );
|
||||||
|
|
||||||
|
update_progress( be );
|
||||||
is_ok = write_account_tree( be, gnc_book_get_root_account( be->primary_book ) );
|
is_ok = write_account_tree( be, gnc_book_get_root_account( be->primary_book ) );
|
||||||
if ( is_ok )
|
if ( is_ok )
|
||||||
{
|
{
|
||||||
|
update_progress( be );
|
||||||
is_ok = write_account_tree( be, gnc_book_get_template_root( be->primary_book ) );
|
is_ok = write_account_tree( be, gnc_book_get_template_root( be->primary_book ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,7 +385,7 @@ write_tx( Transaction* tx, gpointer data )
|
|||||||
g_return_val_if_fail( data != NULL, 0 );
|
g_return_val_if_fail( data != NULL, 0 );
|
||||||
|
|
||||||
s->is_ok = gnc_sql_save_transaction( s->be, QOF_INSTANCE(tx) );
|
s->is_ok = gnc_sql_save_transaction( s->be, QOF_INSTANCE(tx) );
|
||||||
update_save_progress( s->be );
|
update_progress( s->be );
|
||||||
|
|
||||||
if ( s->is_ok )
|
if ( s->is_ok )
|
||||||
{
|
{
|
||||||
@ -396,9 +406,9 @@ write_transactions( GncSqlBackend* be )
|
|||||||
|
|
||||||
data.be = be;
|
data.be = be;
|
||||||
data.is_ok = TRUE;
|
data.is_ok = TRUE;
|
||||||
(void)xaccAccountTreeForEachTransaction( gnc_book_get_root_account( be->primary_book ),
|
(void)xaccAccountTreeForEachTransaction(
|
||||||
write_tx,
|
gnc_book_get_root_account( be->primary_book ), write_tx, &data );
|
||||||
&data );
|
update_progress( be );
|
||||||
return data.is_ok;
|
return data.is_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,6 +426,7 @@ write_template_transactions( GncSqlBackend* be )
|
|||||||
if ( gnc_account_n_descendants( ra ) > 0 )
|
if ( gnc_account_n_descendants( ra ) > 0 )
|
||||||
{
|
{
|
||||||
(void)xaccAccountTreeForEachTransaction( ra, write_tx, &data );
|
(void)xaccAccountTreeForEachTransaction( ra, write_tx, &data );
|
||||||
|
update_progress( be );
|
||||||
}
|
}
|
||||||
|
|
||||||
return data.is_ok;
|
return data.is_ok;
|
||||||
@ -437,6 +448,7 @@ write_schedXactions( GncSqlBackend* be )
|
|||||||
tmpSX = schedXactions->data;
|
tmpSX = schedXactions->data;
|
||||||
is_ok = gnc_sql_save_schedxaction( be, QOF_INSTANCE( tmpSX ) );
|
is_ok = gnc_sql_save_schedxaction( be, QOF_INSTANCE( tmpSX ) );
|
||||||
}
|
}
|
||||||
|
update_progress( be );
|
||||||
|
|
||||||
return is_ok;
|
return is_ok;
|
||||||
}
|
}
|
||||||
@ -453,24 +465,22 @@ write_cb( const gchar* type, gpointer data_p, gpointer be_p )
|
|||||||
if ( pData->write != NULL )
|
if ( pData->write != NULL )
|
||||||
{
|
{
|
||||||
(void)(pData->write)( be );
|
(void)(pData->write)( be );
|
||||||
|
update_progress( be );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_save_progress( GncSqlBackend* be )
|
update_progress( GncSqlBackend* be )
|
||||||
{
|
{
|
||||||
if ( be->be.percentage != NULL )
|
if ( be->be.percentage != NULL )
|
||||||
{
|
(be->be.percentage)( NULL, 101.0 );
|
||||||
double percent_done;
|
}
|
||||||
|
|
||||||
be->operations_done++;
|
static void
|
||||||
percent_done = be->operations_done * 100.0 / be->obj_total;
|
finish_progress( GncSqlBackend* be )
|
||||||
if ( percent_done > 100 )
|
{
|
||||||
{
|
if ( be->be.percentage != NULL )
|
||||||
percent_done = 100;
|
(be->be.percentage)( NULL, -1.0 );
|
||||||
}
|
|
||||||
(be->be.percentage)( NULL, percent_done );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -482,7 +492,7 @@ gnc_sql_sync_all( GncSqlBackend* be, /*@ dependent @*/ QofBook *book )
|
|||||||
g_return_if_fail( book != NULL );
|
g_return_if_fail( book != NULL );
|
||||||
|
|
||||||
ENTER( "book=%p, primary=%p", book, be->primary_book );
|
ENTER( "book=%p, primary=%p", book, be->primary_book );
|
||||||
|
update_progress( be );
|
||||||
(void)reset_version_info( be );
|
(void)reset_version_info( be );
|
||||||
gnc_sql_set_table_version( be, "Gnucash", gnc_get_svn_version() );
|
gnc_sql_set_table_version( be, "Gnucash", gnc_get_svn_version() );
|
||||||
gnc_sql_set_table_version( be, "Gnucash-Resave", GNC_RESAVE_VERSION );
|
gnc_sql_set_table_version( be, "Gnucash-Resave", GNC_RESAVE_VERSION );
|
||||||
@ -542,6 +552,7 @@ gnc_sql_sync_all( GncSqlBackend* be, /*@ dependent @*/ QofBook *book )
|
|||||||
qof_backend_set_error( (QofBackend*)be, ERR_BACKEND_SERVER_ERR );
|
qof_backend_set_error( (QofBackend*)be, ERR_BACKEND_SERVER_ERR );
|
||||||
is_ok = gnc_sql_connection_rollback_transaction( be->conn );
|
is_ok = gnc_sql_connection_rollback_transaction( be->conn );
|
||||||
}
|
}
|
||||||
|
finish_progress( be );
|
||||||
LEAVE( "book=%p", book );
|
LEAVE( "book=%p", book );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user