[Gnucash-changes] Fix test-commodities so it doesn't crash anymore.

Derek Atkins warlord at cvs.gnucash.org
Sun Jan 30 16:54:48 EST 2005


Log Message:
-----------
Fix test-commodities so it doesn't crash anymore.

	* src/engine/gnc-commodity.[ch]:
	  - Use gnc_commodity_table_find_namespace() throughout
	  - fix a crash when adding a new namespace to the commodity table.

Tags:
----
gnucash-gnome2-dev

Modified Files:
--------------
    gnucash:
        ChangeLog
    gnucash/src/engine:
        gnc-commodity.c
        gnc-commodity.h

Revision Data
-------------
Index: ChangeLog
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/ChangeLog,v
retrieving revision 1.1487.2.162
retrieving revision 1.1487.2.163
diff -LChangeLog -LChangeLog -u -r1.1487.2.162 -r1.1487.2.163
--- ChangeLog
+++ ChangeLog
@@ -14,6 +14,10 @@
 	  QofAccessFunc - the patch changes it to the appropriate Get
 	  routine - the QofSetterFunc is OK.
 
+	* src/engine/gnc-commodity.[ch]:
+	  - Use gnc_commodity_table_find_namespace() throughout
+	  - fix a crash when adding a new namespace to the commodity table.
+
 2005-01-26  Derek Atkins  <derek at ihtfp.com>
 
 	Neil Williams' QSF Backend.
Index: gnc-commodity.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/gnc-commodity.h,v
retrieving revision 1.20.4.5
retrieving revision 1.20.4.6
diff -Lsrc/engine/gnc-commodity.h -Lsrc/engine/gnc-commodity.h -u -r1.20.4.5 -r1.20.4.6
--- src/engine/gnc-commodity.h
+++ src/engine/gnc-commodity.h
@@ -727,7 +727,7 @@
  *
  *  @return The a pointer to the namespace found, or NULL if the
  *  namespace doesn't exist. */
-gnc_commodity_namespace * gnc_commodity_table_find_namespace(gnc_commodity_table * table,
+gnc_commodity_namespace * gnc_commodity_table_find_namespace(const gnc_commodity_table * table,
 							     const char * namespace);
 
 /** This function deletes a string from the list of commodity namespaces.
Index: gnc-commodity.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/gnc-commodity.c,v
retrieving revision 1.39.4.11
retrieving revision 1.39.4.12
diff -Lsrc/engine/gnc-commodity.c -Lsrc/engine/gnc-commodity.c -u -r1.39.4.11 -r1.39.4.12
--- src/engine/gnc-commodity.c
+++ src/engine/gnc-commodity.c
@@ -1083,7 +1083,7 @@
 
   if (!table || !namespace || !mnemonic) return NULL;
 
-  nsp = g_hash_table_lookup(table->ns_table, (gpointer)namespace);
+  nsp = gnc_commodity_table_find_namespace(table, namespace);
 
   if(nsp) {
     /*
@@ -1201,7 +1201,7 @@
     return c;
   }
 
-  nsp = g_hash_table_lookup(table->ns_table, (gpointer)ns_name);
+  nsp = gnc_commodity_table_add_namespace(table, ns_name);
   str_cache = gnc_engine_get_string_cache ();
   
   PINFO ("insert %p %s into nsp=%p %s", comm->mnemonic, comm->mnemonic, nsp->cm_table, nsp->name);
@@ -1237,7 +1237,7 @@
 
   gnc_engine_gen_event (&comm->inst.entity, GNC_EVENT_REMOVE);
 
-  nsp = g_hash_table_lookup (table->ns_table, ns_name);
+  nsp = gnc_commodity_table_find_namespace(table, ns_name);
   if (!nsp) return;
 
   nsp->cm_list = g_list_remove(nsp->cm_list, comm);
@@ -1258,7 +1258,7 @@
   
   if(!table || !namespace) { return 0; }
 
-  nsp = g_hash_table_lookup(table->ns_table, (gpointer)namespace);
+  nsp = gnc_commodity_table_find_namespace(table, namespace);
   if(nsp) {
     return 1;
   }
@@ -1344,7 +1344,7 @@
   if (!table)
     return NULL;
 
-  ns = g_hash_table_lookup(table->ns_table, (gpointer)namespace);
+  ns = gnc_commodity_table_find_namespace(table, namespace);
   if (!ns)
     return NULL;
 
@@ -1405,7 +1405,7 @@
       namespace = tmp->data;
       if (regexec(&pattern, namespace, 0, NULL, 0) == 0) {
 	DEBUG("Running list of %s commodities", namespace);
-	ns = g_hash_table_lookup(table->ns_table, namespace);
+	ns = gnc_commodity_table_find_namespace(table, namespace);
 	if (ns) {
 	  g_hash_table_foreach(ns->cm_table, &get_quotables_helper1, (gpointer) &l);
 	}
@@ -1434,7 +1434,7 @@
   
   if (!table) return NULL;
   
-  ns = g_hash_table_lookup(table->ns_table, (gpointer)namespace);
+  ns = gnc_commodity_table_find_namespace(table, namespace);
   if(!ns) 
   {
     GCache *str_cache = gnc_engine_get_string_cache ();
@@ -1454,7 +1454,7 @@
 
 
 gnc_commodity_namespace * 
-gnc_commodity_table_find_namespace(gnc_commodity_table * table,
+gnc_commodity_table_find_namespace(const gnc_commodity_table * table,
 				   const char * namespace) 
 {
   if (!table || !namespace)
@@ -1508,7 +1508,7 @@
 
   if (!table) return;
 
-  ns = g_hash_table_lookup(table->ns_table, namespace);
+  ns = gnc_commodity_table_find_namespace(table, namespace);
   if (!ns)
     return;
 


More information about the gnucash-changes mailing list