r23677 - gnucash/trunk - Bug 721929 - Importing a customer list causes a crash.
Mike Evans
mikee at code.gnucash.org
Fri Jan 10 07:14:08 EST 2014
Author: mikee
Date: 2014-01-10 07:14:08 -0500 (Fri, 10 Jan 2014)
New Revision: 23677
Trac: http://svn.gnucash.org/trac/changeset/23677
Modified:
gnucash/trunk/doc/examples/customers_import.csv
gnucash/trunk/src/plugins/customer_import/dialog-customer-import-gui.c
gnucash/trunk/src/plugins/customer_import/dialog-customer-import.c
Log:
Bug 721929 - Importing a customer list causes a crash.
Seems I omitted some things.
Modified: gnucash/trunk/doc/examples/customers_import.csv
===================================================================
--- gnucash/trunk/doc/examples/customers_import.csv 2014-01-10 12:13:25 UTC (rev 23676)
+++ gnucash/trunk/doc/examples/customers_import.csv 2014-01-10 12:14:08 UTC (rev 23677)
@@ -1,3 +1,6 @@
+# Fields are:
+id,company,name,addr1,addr2,addr3,addr4,phone,fax,email,notes,shipname,shipaddr1,shipaddr2,shipaddr3,shipaddr4,shipphone,shipfax,shipemail
+# Only company and name are compulsory
# This is a comment line
# Good company has no ID and will be allocated one automajically
,Good Company,Accounts Dept.,1 Rich drive,,,,,,,,,,,,,,,
@@ -4,6 +7,11 @@
# Average company has an ID and will be used literally. An already existing
#company with the same ID will be UPDATED. This may not be what you want!
000099,Average Company,Accounts Dept,50 Poor Avenue,,,,,,,,,,,,,,,
+,Academy,Academy,Some Street,,,,555-237-6959,,,,,,,,,,shipmail
+,company,name,addr1,addr2,addr3,addr4,phone,fax,emai,lnotes,shipname,shipaddr1,shipaddr2,shipaddr3,shipaddr4,shipphone,shipfax,shipemail
+,No Address Company,Accounts,,,,,,,,,,,,,,,,
#Just another example after a blank line
,"Bad Company",Accounts,99 Destutute street,,,,,,,,,,,,,,,
+
+
Modified: gnucash/trunk/src/plugins/customer_import/dialog-customer-import-gui.c
===================================================================
--- gnucash/trunk/src/plugins/customer_import/dialog-customer-import-gui.c 2014-01-10 12:13:25 UTC (rev 23676)
+++ gnucash/trunk/src/plugins/customer_import/dialog-customer-import-gui.c 2014-01-10 12:14:08 UTC (rev 23677)
@@ -278,7 +278,7 @@
CustomerImportGui *gui = data;
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
return;
- g_string_assign (gui->regexp, "^(?<id>[^;]*);(?<company>[^;]*);(?<name>[^;]*);(?<addr1>[^;]*);?(?<addr2>[^;]*);?(?<addr3>[^;]*);?(?<addr4>[^;]*);?(?<phone>[^;]*);?(?<fax>[^;]*);?(?<email>[^;]*);?(?<notes>[^;]*);?(?<shipname>[^;]*);?(?<shipaddr1>[^;]*);?(?<shipaddr2>[^;]*);?(?<shipaddr3>[^;]*);?(?<shipadddr4>[^;]*);?(?<shipphone>[^;]*);(?<shipfax>[^;]*);(?<shipemail>[^;]*)"); //;(?<account_posted>[^;]*);(?<memo_posted>[^;]*);(?<accu_splits>[^;]*)$");
+ g_string_assign (gui->regexp, "^(?<id>[^;]*);(?<company>[^;]*);(?<name>[^;]*);(?<addr1>[^;]*);?(?<addr2>[^;]*);?(?<addr3>[^;]*);?(?<addr4>[^;]*);?(?<phone>[^;]*);?(?<fax>[^;]*);?(?<email>[^;]*);?(?<notes>[^;]*);?(?<shipname>[^;]*);?(?<shipaddr1>[^;]*);?(?<shipaddr2>[^;]*);?(?<shipaddr3>[^;]*);?(?<shipaddr4>[^;]*);?(?<shipphone>[^;]*);(?<shipfax>[^;]*);(?<shipemail>[^;]*)"); //;(?<account_posted>[^;]*);(?<memo_posted>[^;]*);(?<accu_splits>[^;]*)$");
gnc_customer_import_gui_filenameChanged_cb (gui->entryFilename, gui);
}
// Comma separated.
@@ -287,7 +287,7 @@
CustomerImportGui *gui = data;
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
return;
- g_string_assign (gui->regexp, "^(?<id>[^,]*),(?<company>[^,]*),(?<name>[^,]*),(?<addr1>[^,]*),?(?<addr2>[^,]*),?(?<addr3>[^,]*),?(?<addr4>[^,]*),?(?<phone>[^,]*),?(?<fax>[^,]*),?(?<email>[^,]*),?(?<notes>[^,]*),?(?<shipname>[^,]*),?(?<shipaddr1>[^,]*),?(?<shipaddr2>[^,]*),?(?<shipaddr3>[^,]*),?(?<shipadddr4>[^,]*),?(?<shipphone>[^,]*),(?<shipfax>[^,]*),(?<shipemail>[^,]*)"); //,(?<account_posted>[^,]*),(?<memo_posted>[^,]*),(?<accu_splits>[^,]*)$");
+ g_string_assign (gui->regexp, "^(?<id>[^,]*),(?<company>[^,]*),(?<name>[^,]*),(?<addr1>[^,]*),?(?<addr2>[^,]*),?(?<addr3>[^,]*),?(?<addr4>[^,]*),?(?<phone>[^,]*),?(?<fax>[^,]*),?(?<email>[^,]*),?(?<notes>[^,]*),?(?<shipname>[^,]*),?(?<shipaddr1>[^,]*),?(?<shipaddr2>[^,]*),?(?<shipaddr3>[^,]*),?(?<shipaddr4>[^,]*),?(?<shipphone>[^,]*),(?<shipfax>[^,]*),(?<shipemail>[^,]*)"); //,(?<account_posted>[^,]*),(?<memo_posted>[^,]*),(?<accu_splits>[^,]*)$");
gnc_customer_import_gui_filenameChanged_cb (gui->entryFilename, gui);
}
// Semicolon separated with quoted strings.
@@ -306,7 +306,7 @@
CustomerImportGui *gui = data;
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
return;
- //g_string_assign (gui->regexp, "^(?<id>[^,]*),(?<company>[^,]*),(?<name>[^,]*),(?<addr1>[^,]*),?(?<addr2>[^,]*),?(?<addr3>[^,]*),?(?<addr4>[^,]*),?(?<phone>[^,]*),?(?<fax>[^,]*),?(?<email>[^,]*),?(?<notes>[^,]*),?(?<shipname>[^,]*),?(?<shipaddr1>[^,]*),?(?<shipaddr2>[^,]*),?(?<shipaddr3>[^,]*),?(?<shipadddr4>[^,]*),?(?<shipphone>[^,]*),(?<shipfax>[^,]*),(?<shipemail>[^,]*)"); //,(?<account_posted>[^,]*),(?<memo_posted>[^,]*),(?<accu_splits>[^,]*)$");
+ //g_string_assign (gui->regexp, "^(?<id>[^,]*),(?<company>[^,]*),(?<name>[^,]*),(?<addr1>[^,]*),?(?<addr2>[^,]*),?(?<addr3>[^,]*),?(?<addr4>[^,]*),?(?<phone>[^,]*),?(?<fax>[^,]*),?(?<email>[^,]*),?(?<notes>[^,]*),?(?<shipname>[^,]*),?(?<shipaddr1>[^,]*),?(?<shipaddr2>[^,]*),?(?<shipaddr3>[^,]*),?(?<shipaddr4>[^,]*),?(?<shipphone>[^,]*),(?<shipfax>[^,]*),(?<shipemail>[^,]*)"); //,(?<account_posted>[^,]*),(?<memo_posted>[^,]*),(?<accu_splits>[^,]*)$");
g_string_assign (gui->regexp, "^((?<id>[^\",]*)|\"(?<id>[^\"]*)\"),((?<company>[^\",]*)|\"(?<company>[^\"]*)\"),((?<name>[^\",]*)|\"(?<name>[^\"]*)\"),((?<addr1>[^\",]*)|\"(?<addr1>[^\"]*)\"),((?<addr2>[^\",]*)|\"(?<addr2>[^\"]*)\"),((?<addr3>[^\",]*)|\"(?<addr3>[^\"]*)\"),((?<addr4>[^\",]*)|\"(?<addr4>[^\"]*)\"),((?<phone>[^\",]*)|\"(?<phone>[^\"]*)\"),((?<fax>[^\",]*)|\"(?<fax>[^\"]*)\"),((?<email>[^\",]*)|\"(?<email>[^\"]*)\"),((?<notes>[^\",]*)|\"(?<notes>[^\"]*)\"),((?<shipname>[^\",]*)|\"(?<shipname>[^\"]*)\"),((?<shipaddr1>[^\",]*)|\"(?<shipaddr1>[^\"]*)\"),((?<shipaddr2>[^\",]*)|\"(?<shipaddr2>[^\"]*)\"),((?<shipaddr3>[^\",]*)|\"(?<shipaddr3>[^\"]*)\"),((?<shipaddr4>[^\",]*)|\"(?<shipaddr4>[^\"]*)\"),((?<shipphone>[^\",]*)|\"(?<shipphone>[^\"]*)\"),((?<shipfax>[^\",]*)|\"(?<shipfax>[^\"]*)\"),((?<shipemail>[^\",]*)|\"(?<shipemail>[^\"]*)\")$");
gnc_customer_import_gui_filenameChanged_cb (gui->entryFilename, gui);
}
Modified: gnucash/trunk/src/plugins/customer_import/dialog-customer-import.c
===================================================================
--- gnucash/trunk/src/plugins/customer_import/dialog-customer-import.c 2014-01-10 12:13:25 UTC (rev 23676)
+++ gnucash/trunk/src/plugins/customer_import/dialog-customer-import.c 2014-01-10 12:14:08 UTC (rev 23677)
@@ -158,6 +158,7 @@
FILL_IN_HELPER ("phone", CI_PHONE);
FILL_IN_HELPER ("fax", CI_FAX);
FILL_IN_HELPER ("email", CI_EMAIL);
+ FILL_IN_HELPER ("notes", CI_NOTES);
FILL_IN_HELPER ("shipname", CI_SHIPNAME);
FILL_IN_HELPER ("shipaddr1", CI_SHIPADDR1);
FILL_IN_HELPER ("shipaddr2", CI_SHIPADDR2);
@@ -198,15 +199,14 @@
-
-
-
void
gnc_customer_import_fix_customers (GtkListStore *store, guint *fixed, guint *deleted, gchar * type)
{
GtkTreeIter iter;
gboolean valid;
- gchar *company, *name, *addr1, *addr2, *addr3, *addr4;
+ gchar *company, *name, *addr1, *addr2, *addr3, *addr4, *phone, *fax, *email,
+ *notes, *shipname, *shipaddr1, *shipaddr2, *shipaddr3, *shipaddr4,
+ *shipphone, *shipfax, *shipemail;
guint dummy;
// allow the call to this function with only GtkListeStore* specified
@@ -229,6 +229,18 @@
CI_ADDR2, &addr2,
CI_ADDR3, &addr3,
CI_ADDR4, &addr4,
+ CI_PHONE, &phone,
+ CI_FAX, &fax,
+ CI_EMAIL, &email,
+ CI_NOTES, ¬es,
+ CI_SHIPNAME, &shipname,
+ CI_SHIPADDR1, &shipaddr1,
+ CI_SHIPADDR2, &shipaddr2,
+ CI_SHIPADDR3, &shipaddr3,
+ CI_SHIPADDR4, &shipaddr4,
+ CI_SHIPPHONE, &shipphone,
+ CI_SHIPFAX, &shipfax,
+ CI_SHIPEMAIL, &shipemail,
-1);
if (strlen(company) == 0)
@@ -238,12 +250,6 @@
// no fix possible -> delete row
gtk_list_store_remove (store, &iter);
(*deleted)++;
- g_free (company);
- g_free (name);
- g_free (addr1);
- g_free (addr2);
- g_free (addr3);
- g_free (addr4);
continue;
}
else
@@ -253,30 +259,26 @@
(*fixed)++;
}
}
- if ((strlen(addr1) == 0) && (strlen(addr2) == 0) &&
- (strlen(addr3) == 0) && (strlen(addr4) == 0))
- {
- // no address given, no fix possible -> delete row
- gtk_list_store_remove (store, &iter);
- (*deleted)++;
- if (strlen(company) == 0)
- // the company cell was fixed -> decrement "fixed" counter
- (*fixed)--;
- g_free (company);
- g_free (name);
- g_free (addr1);
- g_free (addr2);
- g_free (addr3);
- g_free (addr4);
- continue;
- }
-
+
g_free (company);
g_free (name);
g_free (addr1);
g_free (addr2);
g_free (addr3);
g_free (addr4);
+ g_free (phone);
+ g_free (fax);
+ g_free (email);
+ g_free (notes);
+ g_free (shipname);
+ g_free (shipaddr1);
+ g_free (shipaddr2);
+ g_free (shipaddr3);
+ g_free (shipaddr4);
+ g_free (shipphone);
+ g_free (shipfax);
+ g_free (shipemail);
+
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(store), &iter);
}
}
More information about the gnucash-changes
mailing list