diff --git a/ChangeLog b/ChangeLog index dabd55a36e..4f9145dd5a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-01-07 Derek Atkins + + * src/business/business-core/file/* -- don't save half-built data. + Make sure that we're only saving the items that have been fully + created (not half-created). Fixes the cause of bug #102776. + 2003-01-06 Derek Atkins * macros/Makefile.am: include the rest of the macros in the dist. diff --git a/src/business/business-core/file/gnc-customer-xml-v2.c b/src/business/business-core/file/gnc-customer-xml-v2.c index 6113f33124..a062b23a1d 100644 --- a/src/business/business-core/file/gnc-customer-xml-v2.c +++ b/src/business/business-core/file/gnc-customer-xml-v2.c @@ -455,11 +455,25 @@ customer_sixtp_parser_create(void) return sixtp_dom_parser_new(gnc_customer_end_handler, NULL, NULL); } +static gboolean +customer_should_be_saved (GncCustomer *customer) +{ + const char *id; + + /* make sure this is a valid customer before we save it -- should have an ID */ + id = gncCustomerGetID (customer); + if (id == NULL || *id == '\0') + return FALSE; + + return TRUE; +} + static void do_count (gpointer cust_p, gpointer count_p) { int *count = count_p; - (*count)++; + if (customer_should_be_saved (cust_p)) + (*count)++; } static int @@ -477,6 +491,9 @@ xml_add_customer (gpointer cust_p, gpointer out_p) GncCustomer *cust = cust_p; FILE *out = out_p; + if (!customer_should_be_saved (cust_p)) + return; + node = customer_dom_tree_create (cust); xmlElemDump(out, NULL, node); fprintf(out, "\n"); diff --git a/src/business/business-core/file/gnc-employee-xml-v2.c b/src/business/business-core/file/gnc-employee-xml-v2.c index facd437fd6..83d4348106 100644 --- a/src/business/business-core/file/gnc-employee-xml-v2.c +++ b/src/business/business-core/file/gnc-employee-xml-v2.c @@ -341,11 +341,25 @@ employee_sixtp_parser_create(void) return sixtp_dom_parser_new(gnc_employee_end_handler, NULL, NULL); } +static gboolean +employee_should_be_saved (GncEmployee *employee) +{ + const char *id; + + /* make sure this is a valid employee before we save it -- should have an ID */ + id = gncEmployeeGetID (employee); + if (id == NULL || *id == '\0') + return FALSE; + + return TRUE; +} + static void do_count (gpointer employee_p, gpointer count_p) { int *count = count_p; - (*count)++; + if (employee_should_be_saved (employee_p)) + (*count)++; } static int @@ -363,6 +377,9 @@ xml_add_employee (gpointer employee_p, gpointer out_p) GncEmployee *employee = employee_p; FILE *out = out_p; + if (!employee_should_be_saved (employee)) + return; + node = employee_dom_tree_create (employee); xmlElemDump(out, NULL, node); fprintf(out, "\n"); diff --git a/src/business/business-core/file/gnc-invoice-xml-v2.c b/src/business/business-core/file/gnc-invoice-xml-v2.c index ba5cf3e70c..477855f612 100644 --- a/src/business/business-core/file/gnc-invoice-xml-v2.c +++ b/src/business/business-core/file/gnc-invoice-xml-v2.c @@ -470,11 +470,25 @@ invoice_sixtp_parser_create(void) return sixtp_dom_parser_new(gnc_invoice_end_handler, NULL, NULL); } +static gboolean +invoice_should_be_saved (GncInvoice *invoice) +{ + const char *id; + + /* make sure this is a valid invoice before we save it -- should have an ID */ + id = gncInvoiceGetID (invoice); + if (id == NULL || *id == '\0') + return FALSE; + + return TRUE; +} + static void do_count (gpointer invoice_p, gpointer count_p) { int *count = count_p; - (*count)++; + if (invoice_should_be_saved (invoice_p)) + (*count)++; } static int @@ -492,6 +506,9 @@ xml_add_invoice (gpointer invoice_p, gpointer out_p) GncInvoice *invoice = invoice_p; FILE *out = out_p; + if (!invoice_should_be_saved (invoice)) + return; + node = invoice_dom_tree_create (invoice); xmlElemDump(out, NULL, node); fprintf(out, "\n"); diff --git a/src/business/business-core/file/gnc-job-xml-v2.c b/src/business/business-core/file/gnc-job-xml-v2.c index 9a75130829..54ef198dfb 100644 --- a/src/business/business-core/file/gnc-job-xml-v2.c +++ b/src/business/business-core/file/gnc-job-xml-v2.c @@ -275,11 +275,25 @@ job_sixtp_parser_create(void) return sixtp_dom_parser_new(gnc_job_end_handler, NULL, NULL); } +static gboolean +job_should_be_saved (GncJob *job) +{ + const char *id; + + /* make sure this is a valid job before we save it -- should have an ID */ + id = gncJobGetID (job); + if (id == NULL || *id == '\0') + return FALSE; + + return TRUE; +} + static void do_count (gpointer job_p, gpointer count_p) { int *count = count_p; - (*count)++; + if (job_should_be_saved (job_p)) + (*count)++; } static int @@ -297,6 +311,9 @@ xml_add_job (gpointer job_p, gpointer out_p) GncJob *job = job_p; FILE *out = out_p; + if (!job_should_be_saved (job)) + return; + node = job_dom_tree_create (job); xmlElemDump(out, NULL, node); fprintf(out, "\n"); diff --git a/src/business/business-core/file/gnc-order-xml-v2.c b/src/business/business-core/file/gnc-order-xml-v2.c index dc8c4ef8ea..4f803c546b 100644 --- a/src/business/business-core/file/gnc-order-xml-v2.c +++ b/src/business/business-core/file/gnc-order-xml-v2.c @@ -313,11 +313,25 @@ order_sixtp_parser_create(void) return sixtp_dom_parser_new(gnc_order_end_handler, NULL, NULL); } +static gboolean +order_should_be_saved (GncOrder *order) +{ + const char *id; + + /* make sure this is a valid order before we save it -- should have an ID */ + id = gncOrderGetID (order); + if (id == NULL || *id == '\0') + return FALSE; + + return TRUE; +} + static void do_count (gpointer order_p, gpointer count_p) { int *count = count_p; - (*count)++; + if (order_should_be_saved (order_p)) + (*count)++; } static int @@ -335,6 +349,9 @@ xml_add_order (gpointer order_p, gpointer out_p) GncOrder *order = order_p; FILE *out = out_p; + if (!order_should_be_saved (order)) + return; + node = order_dom_tree_create (order); xmlElemDump(out, NULL, node); fprintf(out, "\n"); diff --git a/src/business/business-core/file/gnc-vendor-xml-v2.c b/src/business/business-core/file/gnc-vendor-xml-v2.c index 2bbfd1085c..e0e7743fc3 100644 --- a/src/business/business-core/file/gnc-vendor-xml-v2.c +++ b/src/business/business-core/file/gnc-vendor-xml-v2.c @@ -399,11 +399,25 @@ vendor_sixtp_parser_create(void) return sixtp_dom_parser_new(gnc_vendor_end_handler, NULL, NULL); } +static gboolean +vendor_should_be_saved (GncVendor *vendor) +{ + const char *id; + + /* make sure this is a valid vendor before we save it -- should have an ID */ + id = gncVendorGetID (vendor); + if (id == NULL || *id == '\0') + return FALSE; + + return TRUE; +} + static void do_count (gpointer vendor_p, gpointer count_p) { int *count = count_p; - (*count)++; + if (vendor_should_be_saved (vendor_p)) + (*count)++; } static int @@ -421,6 +435,9 @@ xml_add_vendor (gpointer vendor_p, gpointer out_p) GncVendor *vendor = vendor_p; FILE *out = out_p; + if (!vendor_should_be_saved (vendor)) + return; + node = vendor_dom_tree_create (vendor); xmlElemDump(out, NULL, node); fprintf(out, "\n");