If an object is loaded with a reference to an invoice, order, tax table or bill term which

has not been loaded yet, print a warning message into the trace file.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18308 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Phil Longstaff 2009-09-11 02:09:08 +00:00
parent ca6a78b89d
commit f110ce2c68
4 changed files with 44 additions and 52 deletions

View File

@ -208,7 +208,6 @@ load_billterm_guid( const GncSqlBackend* be, GncSqlRow* row,
{ {
const GValue* val; const GValue* val;
GUID guid; GUID guid;
const GUID* pGuid;
GncBillTerm* term = NULL; GncBillTerm* term = NULL;
g_return_if_fail( be != NULL ); g_return_if_fail( be != NULL );
@ -217,20 +216,19 @@ load_billterm_guid( const GncSqlBackend* be, GncSqlRow* row,
g_return_if_fail( table_row != NULL ); g_return_if_fail( table_row != NULL );
val = gnc_sql_row_get_value_at_col_name( row, table_row->col_name ); val = gnc_sql_row_get_value_at_col_name( row, table_row->col_name );
if( val == NULL || !G_VALUE_HOLDS_STRING( val ) || g_value_get_string( val ) == NULL ) { if( val != NULL && G_VALUE_HOLDS_STRING( val ) && g_value_get_string( val ) != NULL ) {
pGuid = NULL;
} else {
string_to_guid( g_value_get_string( val ), &guid ); string_to_guid( g_value_get_string( val ), &guid );
pGuid = &guid; term = gncBillTermLookup( be->primary_book, &guid );
} if( term != NULL ) {
if( pGuid != NULL ) { if( table_row->gobj_param_name != NULL ) {
term = gncBillTermLookup( be->primary_book, pGuid ); g_object_set( pObject, table_row->gobj_param_name, term, NULL );
} else {
(*setter)( pObject, (const gpointer)term );
}
} else {
PWARN( "Billterm ref '%s' not found", g_value_get_string( val ) );
}
} }
if( table_row->gobj_param_name != NULL ) {
g_object_set( pObject, table_row->gobj_param_name, term, NULL );
} else {
(*setter)( pObject, (const gpointer)term );
}
} }
static GncSqlColumnTypeHandler billterm_guid_handler static GncSqlColumnTypeHandler billterm_guid_handler

View File

@ -253,7 +253,6 @@ load_invoice_guid( const GncSqlBackend* be, GncSqlRow* row,
{ {
const GValue* val; const GValue* val;
GUID guid; GUID guid;
const GUID* pGuid;
GncInvoice* invoice = NULL; GncInvoice* invoice = NULL;
g_return_if_fail( be != NULL ); g_return_if_fail( be != NULL );
@ -262,20 +261,19 @@ load_invoice_guid( const GncSqlBackend* be, GncSqlRow* row,
g_return_if_fail( table_row != NULL ); g_return_if_fail( table_row != NULL );
val = gnc_sql_row_get_value_at_col_name( row, table_row->col_name ); val = gnc_sql_row_get_value_at_col_name( row, table_row->col_name );
if( val == NULL || !G_VALUE_HOLDS_STRING( val ) || g_value_get_string( val ) == NULL ) { if( val != NULL && G_VALUE_HOLDS_STRING( val ) && g_value_get_string( val ) != NULL ) {
pGuid = NULL;
} else {
string_to_guid( g_value_get_string( val ), &guid ); string_to_guid( g_value_get_string( val ), &guid );
pGuid = &guid; invoice = gncInvoiceLookup( be->primary_book, &guid );
} if( invoice != NULL ) {
if( pGuid != NULL ) { if( table_row->gobj_param_name != NULL ) {
invoice = gncInvoiceLookup( be->primary_book, pGuid ); g_object_set( pObject, table_row->gobj_param_name, invoice, NULL );
} else {
(*setter)( pObject, (const gpointer)invoice );
}
} else {
PWARN( "Invoice ref '%s' not found", g_value_get_string( val ) );
}
} }
if( table_row->gobj_param_name != NULL ) {
g_object_set( pObject, table_row->gobj_param_name, invoice, NULL );
} else {
(*setter)( pObject, (const gpointer)invoice );
}
} }
static GncSqlColumnTypeHandler invoice_guid_handler static GncSqlColumnTypeHandler invoice_guid_handler

View File

@ -198,7 +198,6 @@ load_order_guid( const GncSqlBackend* be, GncSqlRow* row,
{ {
const GValue* val; const GValue* val;
GUID guid; GUID guid;
const GUID* pGuid;
GncOrder* order = NULL; GncOrder* order = NULL;
g_return_if_fail( be != NULL ); g_return_if_fail( be != NULL );
@ -207,20 +206,19 @@ load_order_guid( const GncSqlBackend* be, GncSqlRow* row,
g_return_if_fail( table_row != NULL ); g_return_if_fail( table_row != NULL );
val = gnc_sql_row_get_value_at_col_name( row, table_row->col_name ); val = gnc_sql_row_get_value_at_col_name( row, table_row->col_name );
if( val == NULL || !G_VALUE_HOLDS_STRING( val ) || g_value_get_string( val ) == NULL ) { if( val != NULL && G_VALUE_HOLDS_STRING( val ) && g_value_get_string( val ) != NULL ) {
pGuid = NULL;
} else {
string_to_guid( g_value_get_string( val ), &guid ); string_to_guid( g_value_get_string( val ), &guid );
pGuid = &guid; order = gncOrderLookup( be->primary_book, &guid );
} if( order != NULL ) {
if( pGuid != NULL ) { if( table_row->gobj_param_name != NULL ) {
order = gncOrderLookup( be->primary_book, pGuid ); g_object_set( pObject, table_row->gobj_param_name, order, NULL );
} else {
(*setter)( pObject, (const gpointer)order );
}
} else {
PWARN( "Order ref '%s' not found", g_value_get_string( val ) );
}
} }
if( table_row->gobj_param_name != NULL ) {
g_object_set( pObject, table_row->gobj_param_name, order, NULL );
} else {
(*setter)( pObject, (const gpointer)order );
}
} }
static GncSqlColumnTypeHandler order_guid_handler static GncSqlColumnTypeHandler order_guid_handler

View File

@ -393,7 +393,6 @@ load_taxtable_guid( const GncSqlBackend* be, GncSqlRow* row,
{ {
const GValue* val; const GValue* val;
GUID guid; GUID guid;
const GUID* pGuid;
GncTaxTable* taxtable = NULL; GncTaxTable* taxtable = NULL;
g_return_if_fail( be != NULL ); g_return_if_fail( be != NULL );
@ -402,19 +401,18 @@ load_taxtable_guid( const GncSqlBackend* be, GncSqlRow* row,
g_return_if_fail( table_row != NULL ); g_return_if_fail( table_row != NULL );
val = gnc_sql_row_get_value_at_col_name( row, table_row->col_name ); val = gnc_sql_row_get_value_at_col_name( row, table_row->col_name );
if( val == NULL || !G_VALUE_HOLDS_STRING( val ) || g_value_get_string( val ) == NULL ) { if( val != NULL && G_VALUE_HOLDS_STRING( val ) && g_value_get_string( val ) != NULL ) {
pGuid = NULL;
} else {
string_to_guid( g_value_get_string( val ), &guid ); string_to_guid( g_value_get_string( val ), &guid );
pGuid = &guid; taxtable = gncTaxTableLookup( be->primary_book, &guid );
} if( taxtable != NULL ) {
if( pGuid != NULL ) { if( table_row->gobj_param_name != NULL ) {
taxtable = gncTaxTableLookup( be->primary_book, pGuid ); g_object_set( pObject, table_row->gobj_param_name, taxtable, NULL );
} } else {
if( table_row->gobj_param_name != NULL ) { (*setter)( pObject, (const gpointer)taxtable );
g_object_set( pObject, table_row->gobj_param_name, taxtable, NULL ); }
} else { } else {
(*setter)( pObject, (const gpointer)taxtable ); PWARN( "Taxtable ref '%s' not found", g_value_get_string( val ) );
}
} }
} }