r18308 - gnucash/trunk/src/business/business-core/sql - If an object is loaded with a reference to an invoice, order, tax table or bill term which
Phil Longstaff
plongstaff at code.gnucash.org
Thu Sep 10 22:09:08 EDT 2009
Author: plongstaff
Date: 2009-09-10 22:09:08 -0400 (Thu, 10 Sep 2009)
New Revision: 18308
Trac: http://svn.gnucash.org/trac/changeset/18308
Modified:
gnucash/trunk/src/business/business-core/sql/gnc-bill-term-sql.c
gnucash/trunk/src/business/business-core/sql/gnc-invoice-sql.c
gnucash/trunk/src/business/business-core/sql/gnc-order-sql.c
gnucash/trunk/src/business/business-core/sql/gnc-tax-table-sql.c
Log:
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.
Modified: gnucash/trunk/src/business/business-core/sql/gnc-bill-term-sql.c
===================================================================
--- gnucash/trunk/src/business/business-core/sql/gnc-bill-term-sql.c 2009-09-11 02:08:09 UTC (rev 18307)
+++ gnucash/trunk/src/business/business-core/sql/gnc-bill-term-sql.c 2009-09-11 02:09:08 UTC (rev 18308)
@@ -208,7 +208,6 @@
{
const GValue* val;
GUID guid;
- const GUID* pGuid;
GncBillTerm* term = NULL;
g_return_if_fail( be != NULL );
@@ -217,20 +216,19 @@
g_return_if_fail( table_row != NULL );
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 ) {
- pGuid = NULL;
- } else {
+ if( val != NULL && G_VALUE_HOLDS_STRING( val ) && g_value_get_string( val ) != NULL ) {
string_to_guid( g_value_get_string( val ), &guid );
- pGuid = &guid;
- }
- if( pGuid != NULL ) {
- term = gncBillTermLookup( be->primary_book, pGuid );
+ term = gncBillTermLookup( be->primary_book, &guid );
+ if( term != NULL ) {
+ if( table_row->gobj_param_name != NULL ) {
+ 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
Modified: gnucash/trunk/src/business/business-core/sql/gnc-invoice-sql.c
===================================================================
--- gnucash/trunk/src/business/business-core/sql/gnc-invoice-sql.c 2009-09-11 02:08:09 UTC (rev 18307)
+++ gnucash/trunk/src/business/business-core/sql/gnc-invoice-sql.c 2009-09-11 02:09:08 UTC (rev 18308)
@@ -253,7 +253,6 @@
{
const GValue* val;
GUID guid;
- const GUID* pGuid;
GncInvoice* invoice = NULL;
g_return_if_fail( be != NULL );
@@ -262,20 +261,19 @@
g_return_if_fail( table_row != NULL );
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 ) {
- pGuid = NULL;
- } else {
+ if( val != NULL && G_VALUE_HOLDS_STRING( val ) && g_value_get_string( val ) != NULL ) {
string_to_guid( g_value_get_string( val ), &guid );
- pGuid = &guid;
- }
- if( pGuid != NULL ) {
- invoice = gncInvoiceLookup( be->primary_book, pGuid );
+ invoice = gncInvoiceLookup( be->primary_book, &guid );
+ if( invoice != NULL ) {
+ if( table_row->gobj_param_name != NULL ) {
+ 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
Modified: gnucash/trunk/src/business/business-core/sql/gnc-order-sql.c
===================================================================
--- gnucash/trunk/src/business/business-core/sql/gnc-order-sql.c 2009-09-11 02:08:09 UTC (rev 18307)
+++ gnucash/trunk/src/business/business-core/sql/gnc-order-sql.c 2009-09-11 02:09:08 UTC (rev 18308)
@@ -198,7 +198,6 @@
{
const GValue* val;
GUID guid;
- const GUID* pGuid;
GncOrder* order = NULL;
g_return_if_fail( be != NULL );
@@ -207,20 +206,19 @@
g_return_if_fail( table_row != NULL );
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 ) {
- pGuid = NULL;
- } else {
+ if( val != NULL && G_VALUE_HOLDS_STRING( val ) && g_value_get_string( val ) != NULL ) {
string_to_guid( g_value_get_string( val ), &guid );
- pGuid = &guid;
- }
- if( pGuid != NULL ) {
- order = gncOrderLookup( be->primary_book, pGuid );
+ order = gncOrderLookup( be->primary_book, &guid );
+ if( order != NULL ) {
+ if( table_row->gobj_param_name != NULL ) {
+ 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
Modified: gnucash/trunk/src/business/business-core/sql/gnc-tax-table-sql.c
===================================================================
--- gnucash/trunk/src/business/business-core/sql/gnc-tax-table-sql.c 2009-09-11 02:08:09 UTC (rev 18307)
+++ gnucash/trunk/src/business/business-core/sql/gnc-tax-table-sql.c 2009-09-11 02:09:08 UTC (rev 18308)
@@ -393,7 +393,6 @@
{
const GValue* val;
GUID guid;
- const GUID* pGuid;
GncTaxTable* taxtable = NULL;
g_return_if_fail( be != NULL );
@@ -402,20 +401,19 @@
g_return_if_fail( table_row != NULL );
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 ) {
- pGuid = NULL;
- } else {
+ if( val != NULL && G_VALUE_HOLDS_STRING( val ) && g_value_get_string( val ) != NULL ) {
string_to_guid( g_value_get_string( val ), &guid );
- pGuid = &guid;
+ taxtable = gncTaxTableLookup( be->primary_book, &guid );
+ if( taxtable != NULL ) {
+ if( table_row->gobj_param_name != NULL ) {
+ g_object_set( pObject, table_row->gobj_param_name, taxtable, NULL );
+ } else {
+ (*setter)( pObject, (const gpointer)taxtable );
+ }
+ } else {
+ PWARN( "Taxtable ref '%s' not found", g_value_get_string( val ) );
+ }
}
- if( pGuid != NULL ) {
- taxtable = gncTaxTableLookup( be->primary_book, pGuid );
- }
- if( table_row->gobj_param_name != NULL ) {
- g_object_set( pObject, table_row->gobj_param_name, taxtable, NULL );
- } else {
- (*setter)( pObject, (const gpointer)taxtable );
- }
}
static GncSqlColumnTypeHandler taxtable_guid_handler
More information about the gnucash-changes
mailing list