[Gnucash-changes] r14281 - gnucash/branches/register-rewrite/src - Internalize the commodity table membership within the commodity.

Chris Shoemaker chris at cvs.gnucash.org
Wed May 31 00:30:20 EDT 2006


Author: chris
Date: 2006-05-31 00:30:18 -0400 (Wed, 31 May 2006)
New Revision: 14281
Trac: http://svn.gnucash.org/trac/changeset/14281

Modified:
   gnucash/branches/register-rewrite/src/backend/file/io-example-account.c
   gnucash/branches/register-rewrite/src/backend/file/io-gncbin-r.c
   gnucash/branches/register-rewrite/src/backend/file/io-gncxml-v1.c
   gnucash/branches/register-rewrite/src/backend/file/io-gncxml-v2.c
   gnucash/branches/register-rewrite/src/backend/postgres/price.c
   gnucash/branches/register-rewrite/src/backend/postgres/test/test-db.c
   gnucash/branches/register-rewrite/src/engine/Account.c
   gnucash/branches/register-rewrite/src/engine/gnc-commodity.c
   gnucash/branches/register-rewrite/src/engine/gnc-commodity.h
   gnucash/branches/register-rewrite/src/engine/gw-engine-spec.scm
   gnucash/branches/register-rewrite/src/engine/iso-currencies-to-c
   gnucash/branches/register-rewrite/src/engine/test-core/test-engine-stuff.c
   gnucash/branches/register-rewrite/src/engine/test/test-commodities.c
   gnucash/branches/register-rewrite/src/experimental/cgi-bin/hello.c
   gnucash/branches/register-rewrite/src/gnome-utils/dialog-commodity.c
   gnucash/branches/register-rewrite/src/gnome/dialog-commodities.c
   gnucash/branches/register-rewrite/src/import-export/binary-import/druid-commodity.c
   gnucash/branches/register-rewrite/src/import-export/qif-import/druid-qif-import.c
Log:
   Internalize the commodity table membership within the commodity.
   gnc_commoditys now handle their own gnc_commodity_table membership 
   automatically.  New commodities are automatically inserted in to their table
   and automatically removed from their table when they're destroyed.
   
   Any changes to a commodity that affect its key in the table (e.g. mnemonic
   or namespace) are handled internally by removing and re-adding the 
   commodity.
   
   gnc_commodity_table_insert() and gnc_commodity_table_remove() are now
   private.


Modified: gnucash/branches/register-rewrite/src/backend/file/io-example-account.c
===================================================================
--- gnucash/branches/register-rewrite/src/backend/file/io-example-account.c	2006-05-31 04:07:31 UTC (rev 14280)
+++ gnucash/branches/register-rewrite/src/backend/file/io-example-account.c	2006-05-31 04:30:18 UTC (rev 14281)
@@ -116,7 +116,6 @@
     {
         PWARN("unable to find global commodity for %s adding new",
                   gnc_commodity_get_unique_name(com));
-        gnc_commodity_table_insert(tbl, com);
     }
     else
     {

Modified: gnucash/branches/register-rewrite/src/backend/file/io-gncbin-r.c
===================================================================
--- gnucash/branches/register-rewrite/src/backend/file/io-gncbin-r.c	2006-05-31 04:07:31 UTC (rev 14280)
+++ gnucash/branches/register-rewrite/src/backend/file/io-gncbin-r.c	2006-05-31 04:30:18 UTC (rev 14281)
@@ -385,7 +385,6 @@
       old = gnc_commodity_new(book, currency_name,
                               GNC_COMMODITY_NS_LEGACY, currency_name,
                               0, 100000);
-      old = gnc_commodity_table_insert(table, old);
     }
     return old;
   }

Modified: gnucash/branches/register-rewrite/src/backend/file/io-gncxml-v1.c
===================================================================
--- gnucash/branches/register-rewrite/src/backend/file/io-gncxml-v1.c	2006-05-31 04:07:31 UTC (rev 14280)
+++ gnucash/branches/register-rewrite/src/backend/file/io-gncxml-v1.c	2006-05-31 04:30:18 UTC (rev 14281)
@@ -1943,7 +1943,6 @@
 
       if(ctab)
       {
-        gnc_commodity_table_insert(ctab, comm);
         ok = TRUE;
       }
     }

Modified: gnucash/branches/register-rewrite/src/backend/file/io-gncxml-v2.c
===================================================================
--- gnucash/branches/register-rewrite/src/backend/file/io-gncxml-v2.c	2006-05-31 04:07:31 UTC (rev 14280)
+++ gnucash/branches/register-rewrite/src/backend/file/io-gncxml-v2.c	2006-05-31 04:30:18 UTC (rev 14281)
@@ -110,7 +110,6 @@
     {
         PWARN("unable to find global commodity for %s adding new",
                   gnc_commodity_get_unique_name(com));
-        gnc_commodity_table_insert(tbl, com);
     }
     else
     {
@@ -146,7 +145,6 @@
     {
         PWARN("unable to find global commodity for %s adding new",
                   gnc_commodity_get_unique_name(com));
-        gnc_commodity_table_insert(tbl, com);
     }
     else
     {
@@ -200,12 +198,6 @@
 static gboolean
 add_commodity_local(sixtp_gdv2 *data, gnc_commodity *com)
 {
-    gnc_commodity_table *table;
-
-    table = gnc_book_get_commodity_table (data->book);
-
-    gnc_commodity_table_insert(table, com);
-
     data->counter.commodities_loaded++;
     run_callback(data, "commodities");
 

Modified: gnucash/branches/register-rewrite/src/backend/postgres/price.c
===================================================================
--- gnucash/branches/register-rewrite/src/backend/postgres/price.c	2006-05-31 04:07:31 UTC (rev 14280)
+++ gnucash/branches/register-rewrite/src/backend/postgres/price.c	2006-05-31 04:30:18 UTC (rev 14281)
@@ -78,8 +78,6 @@
                                DB_GET_VAL("mnemonic",j),
                                DB_GET_VAL("code",j),
                                atoi(DB_GET_VAL("fraction",j)));
-   
-      gnc_commodity_table_insert (comtab, com);
    }
    return NULL;
 }

Modified: gnucash/branches/register-rewrite/src/backend/postgres/test/test-db.c
===================================================================
--- gnucash/branches/register-rewrite/src/backend/postgres/test/test-db.c	2006-05-31 04:07:31 UTC (rev 14280)
+++ gnucash/branches/register-rewrite/src/backend/postgres/test/test-db.c	2006-05-31 04:30:18 UTC (rev 14281)
@@ -325,8 +325,7 @@
                                           add_commodity_to_delete, &cdi);
 
     for (node = cdi.to_delete; node; node = node->next)
-        gnc_commodity_table_remove(gnc_book_get_commodity_table(book),
-                                   node->data);
+        gnc_commodity_destroy(node->data);
 
     g_list_free(cdi.to_delete);
     g_hash_table_destroy(cdi.hash);

Modified: gnucash/branches/register-rewrite/src/engine/Account.c
===================================================================
--- gnucash/branches/register-rewrite/src/engine/Account.c	2006-05-31 04:07:31 UTC (rev 14280)
+++ gnucash/branches/register-rewrite/src/engine/Account.c	2006-05-31 04:30:18 UTC (rev 14281)
@@ -1228,7 +1228,6 @@
 DxaccAccountSetCurrency (Account * acc, gnc_commodity * currency)
 {
   const char *string;
-  gnc_commodity *commodity;
 
   if ((!acc) || (!currency)) return;
 
@@ -1238,12 +1237,6 @@
                         kvp_value_new_string(string));
   mark_account (acc);
   xaccAccountCommitEdit(acc);
-
-  commodity = DxaccAccountGetCurrency (acc);
-  if (!commodity)
-  {
-    gnc_commodity_table_insert (gnc_commodity_table_get_table (acc->inst.book), currency);
-  }
 }
 
 /********************************************************************\

Modified: gnucash/branches/register-rewrite/src/engine/gnc-commodity.c
===================================================================
--- gnucash/branches/register-rewrite/src/engine/gnc-commodity.c	2006-05-31 04:07:31 UTC (rev 14280)
+++ gnucash/branches/register-rewrite/src/engine/gnc-commodity.c	2006-05-31 04:30:18 UTC (rev 14281)
@@ -174,6 +174,10 @@
 	sizeof(multiple_quote_sources) / sizeof(gnc_quote_source);
 static GList *new_quote_sources = NULL;
 
+static gnc_commodity * gnc_commodity_table_insert(gnc_commodity_table * table, 
+                                                  gnc_commodity * comm); 
+static void gnc_commodity_table_remove(gnc_commodity_table * table,
+                                       gnc_commodity * comm);
 
 /********************************************************************
  * gnc_quote_source_fq_installed
@@ -531,14 +535,7 @@
 
   qof_instance_init (&retval->inst, GNC_ID_COMMODITY, book);
   table = gnc_commodity_table_get_table(book);
-  if (namespace) {
-    retval->namespace = gnc_commodity_table_find_namespace(table, namespace);
-    if (!retval->namespace)
-      retval->namespace = gnc_commodity_table_add_namespace(table, namespace, book);
-  } else {
-    retval->namespace = NULL;
-  }
-  
+  retval->namespace = gnc_commodity_table_add_namespace(table, namespace, book);
   retval->fullname = CACHE_INSERT(fullname);
   retval->mnemonic = CACHE_INSERT(mnemonic);
   retval->cusip = CACHE_INSERT(cusip);
@@ -554,6 +551,7 @@
     retval->quote_source = gnc_quote_source_lookup_by_internal("currency");
   qof_event_gen (&retval->inst.entity, QOF_EVENT_CREATE, NULL);
 
+  retval = gnc_commodity_table_insert(table, retval);
   return retval;
 }
 
@@ -598,7 +596,7 @@
   g_free(cm);
 }
 
-void
+static void
 gnc_commodity_copy(gnc_commodity * dest, gnc_commodity *src)
 {
   gnc_commodity_set_fullname (dest, src->fullname);
@@ -610,7 +608,7 @@
   gnc_commodity_set_quote_tz (dest, src->quote_tz);
 }
 
-gnc_commodity *
+static gnc_commodity *
 gnc_commodity_clone(gnc_commodity *src)
 {
   gnc_commodity * dest = g_new0(gnc_commodity, 1);
@@ -618,14 +616,14 @@
   dest->fullname = CACHE_INSERT(src->fullname);
   dest->mnemonic = CACHE_INSERT(src->mnemonic);
   dest->cusip = CACHE_INSERT(src->cusip);
+  dest->fraction = src->fraction;
+  dest->mark = 0;
+
+  dest->quote_flag = src->quote_flag;
   dest->quote_tz = CACHE_INSERT(src->quote_tz);
 
   dest->namespace = src->namespace;
 
-  dest->mark = 0;
-  dest->fraction = src->fraction;
-  dest->quote_flag = src->quote_flag;
-
   gnc_commodity_set_quote_source (dest, gnc_commodity_get_quote_source (src));
 
   reset_printname(dest);
@@ -783,15 +781,22 @@
 void
 gnc_commodity_set_mnemonic(gnc_commodity * cm, const char * mnemonic) 
 {
+  gnc_commodity_table *table;
   if (!cm) return;
   if (cm->mnemonic == mnemonic) return;
 
   gnc_commodity_begin_edit(cm);
+  table = gnc_commodity_table_get_table(qof_instance_get_book(&cm->inst));
+  gnc_commodity_table_remove(table, cm);
   CACHE_REPLACE(cm->mnemonic, mnemonic);
 
   mark_commodity_dirty (cm);
   reset_printname(cm);
   reset_unique_name(cm);
+  {
+      gnc_commodity *same = gnc_commodity_table_insert(table, cm);
+      g_assert(same == cm);
+  }
   gnc_commodity_commit_edit(cm);
 }
 
@@ -809,6 +814,7 @@
   if (!cm) return;
   book = qof_instance_get_book (&cm->inst);
   table = gnc_commodity_table_get_table(book);
+  gnc_commodity_table_remove(table, cm);
   nsp = gnc_commodity_table_add_namespace(table, namespace, book);
   if (cm->namespace == nsp)
     return;
@@ -820,6 +826,10 @@
   mark_commodity_dirty(cm);
   reset_printname(cm);
   reset_unique_name(cm);
+  { 
+      gnc_commodity *same = gnc_commodity_table_insert(table, cm);
+      g_assert(same == cm);
+  }
   gnc_commodity_commit_edit(cm);
 }
 
@@ -1218,12 +1228,21 @@
 }
 
 
-/********************************************************************
- * gnc_commodity_table_insert
- * add a commodity to the table. 
- ********************************************************************/
-
-gnc_commodity *
+/** Add a new commodity to the commodity table.  This routine handles
+ *  the cases where the commodity already exists in the database (does
+ *  nothing), or another entries has the same namespace and mnemonic
+ *  (updates the existing entry).
+ *
+ *  @param table A pointer to the commodity table 
+ *
+ *  @param comm A pointer to the commodity to add.
+ *
+ *  @return The added commodity. Null on error.
+ *
+ *  @note The commodity pointer passed to this function should not be
+ *  used after its return, as it may have been destroyed.  Use the
+ *  return value which is guaranteed to be valid. */
+static gnc_commodity *
 gnc_commodity_table_insert(gnc_commodity_table * table, 
                            gnc_commodity * comm) 
 {
@@ -1265,12 +1284,13 @@
   return comm;
 }
 
-/********************************************************************
- * gnc_commodity_table_remove
- * remove a commodity from the table. 
- ********************************************************************/
-
-void
+/** Remove a commodity from the commodity table. If the commodity to
+ *  remove doesn't exist, nothing happens.
+ *
+ *  @param table A pointer to the commodity table 
+ *
+ *  @param comm A pointer to the commodity to remove. */
+static void
 gnc_commodity_table_remove(gnc_commodity_table * table,
                            gnc_commodity * comm)
 {

Modified: gnucash/branches/register-rewrite/src/engine/gnc-commodity.h
===================================================================
--- gnucash/branches/register-rewrite/src/engine/gnc-commodity.h	2006-05-31 04:07:31 UTC (rev 14280)
+++ gnucash/branches/register-rewrite/src/engine/gnc-commodity.h	2006-05-31 04:30:18 UTC (rev 14281)
@@ -280,11 +280,6 @@
  */
 void  gnc_commodity_destroy(gnc_commodity * cm);
 
-/** Copy src into dest */
-void  gnc_commodity_copy(gnc_commodity * dest, gnc_commodity *src);
-
-/** allocate and copy */
-gnc_commodity * gnc_commodity_clone(gnc_commodity *src);
 /** @} */
 
 
@@ -651,32 +646,6 @@
  @{
 */
 
-/** Add a new commodity to the commodity table.  This routine handles
- *  the cases where the commodity already exists in the database (does
- *  nothing), or another entries has the same namespace and mnemonic
- *  (updates the existing entry).
- *
- *  @param table A pointer to the commodity table 
- *
- *  @param comm A pointer to the commodity to add.
- *
- *  @return The added commodity. Null on error.
- *
- *  @note The commodity pointer passed to this function should not be
- *  used after its return, as it may have been destroyed.  Use the
- *  return value which is guaranteed to be valid. */
-gnc_commodity * gnc_commodity_table_insert(gnc_commodity_table * table,
-                                           gnc_commodity * comm);
-
-/** Remove a commodity from the commodity table. If the commodity to
- *  remove doesn't exist, nothing happens.
- *
- *  @param table A pointer to the commodity table 
- *
- *  @param comm A pointer to the commodity to remove. */
-void gnc_commodity_table_remove(gnc_commodity_table * table,
-				gnc_commodity * comm);
-
 /** Add all the standard namespaces and currencies to the commodity
  *  table.  This routine creates the namespaces for the NYSE, NASDAQ,
  *  etc.  It also adds all of the ISO 4217 currencies to the commodity

Modified: gnucash/branches/register-rewrite/src/engine/gw-engine-spec.scm
===================================================================
--- gnucash/branches/register-rewrite/src/engine/gw-engine-spec.scm	2006-05-31 04:07:31 UTC (rev 14280)
+++ gnucash/branches/register-rewrite/src/engine/gw-engine-spec.scm	2006-05-31 04:30:18 UTC (rev 14281)
@@ -2149,15 +2149,6 @@
 
 (gw:wrap-function
  ws
- 'gnc:commodity-table-insert
- '<gnc:commodity*>
- "gnc_commodity_table_insert"
- '((<gnc:commodity-table*> table)
-   (<gnc:commodity*> commodity))
- "Add a commodity to the table.")
-
-(gw:wrap-function
- ws
  'gnc:commodity-table-has-namespace
  '<gw:bool>
  "gnc_commodity_table_has_namespace"

Modified: gnucash/branches/register-rewrite/src/engine/iso-currencies-to-c
===================================================================
--- gnucash/branches/register-rewrite/src/engine/iso-currencies-to-c	2006-05-31 04:07:31 UTC (rev 14280)
+++ gnucash/branches/register-rewrite/src/engine/iso-currencies-to-c	2006-05-31 04:30:18 UTC (rev 14281)
@@ -46,10 +46,6 @@
                                          ~S);\n
     if(!c) {
       PWARN(\"failed to create commodity for currency %s\", fullname);
-    } else {
-      if(!gnc_commodity_table_insert(table, c)) {
-        PWARN(\"failed to insert %s into commodity table\", fullname);
-      }
     }
   }\n"
          fullname

Modified: gnucash/branches/register-rewrite/src/engine/test/test-commodities.c
===================================================================
--- gnucash/branches/register-rewrite/src/engine/test/test-commodities.c	2006-05-31 04:07:31 UTC (rev 14280)
+++ gnucash/branches/register-rewrite/src/engine/test/test-commodities.c	2006-05-31 04:30:18 UTC (rev 14281)
@@ -128,13 +128,13 @@
     }
     
     {
-        int i, j, num_total = 0;
+        int i, j;
         gnc_commodity_table *tbl;
         gnc_commodity *coms[20];
         QofBook *book;
 
         book = qof_book_new ();
-        tbl = gnc_commodity_table_new ();
+        tbl = gnc_commodity_table_get_table (book);
 
         do_test(gnc_commodity_table_get_size(tbl) == 0,
                 "test size for 0 table");
@@ -143,18 +143,16 @@
         {
             coms[i] = get_random_commodity(book);
 
-            if (!gnc_commodity_table_lookup(
-                tbl, gnc_commodity_get_namespace(coms[i]),
-                gnc_commodity_get_mnemonic(coms[i])))
-                num_total++;
-            do_test(
-                gnc_commodity_table_insert(tbl, coms[i]) != NULL,
-                "insert test");
+            do_test(coms[i] == gnc_commodity_table_lookup(
+                        tbl, gnc_commodity_get_namespace(coms[i]),
+                        gnc_commodity_get_mnemonic(coms[i])), "lookup test");
 
             do_test_args(
-                (int)gnc_commodity_table_get_size(tbl) == num_total,
+                (int)gnc_commodity_table_get_size(tbl) == (i+1),
+                "Dumb test warning: count will fail incorrectly if random\n"
+                "commodity generator generates the same commodity twice.\n"
                 "test next size table", __FILE__, __LINE__,
-                "should be %d and is %d", num_total,
+                "should be %d and is %d", i+1,
                 gnc_commodity_table_get_size(tbl));
 
             for(j = 0; j <= i; j++)

Modified: gnucash/branches/register-rewrite/src/engine/test-core/test-engine-stuff.c
===================================================================
--- gnucash/branches/register-rewrite/src/engine/test-core/test-engine-stuff.c	2006-05-31 04:07:31 UTC (rev 14280)
+++ gnucash/branches/register-rewrite/src/engine/test-core/test-engine-stuff.c	2006-05-31 04:30:18 UTC (rev 14281)
@@ -565,9 +565,6 @@
     g_free(name);
     g_free(cusip);
 
-    if (table)
-      ret = gnc_commodity_table_insert (table, ret);
-
     return ret;
 }
 
@@ -622,9 +619,7 @@
     {
       gnc_commodity *com = com_node->data;
 
-      gnc_commodity_table_remove (table, com);
       make_random_changes_to_commodity (com);
-      gnc_commodity_table_insert (table, com);
     }
 
     g_list_free (commodities);

Modified: gnucash/branches/register-rewrite/src/experimental/cgi-bin/hello.c
===================================================================
--- gnucash/branches/register-rewrite/src/experimental/cgi-bin/hello.c	2006-05-31 04:07:31 UTC (rev 14280)
+++ gnucash/branches/register-rewrite/src/experimental/cgi-bin/hello.c	2006-05-31 04:30:18 UTC (rev 14281)
@@ -32,9 +32,7 @@
 
    /* dirty little hack to work around commodity borkeness */
    {
-      gnc_commodity_table *t = gnc_engine_commodities ();
       gnc_commodity *cm = gnc_commodity_new ("US Dollar", "ISO4217", "USD",  "840", 100);
-      gnc_commodity_table_insert (t, cm);
    }
 
    /* contact the database, which is a flat file for this demo */

Modified: gnucash/branches/register-rewrite/src/gnome/dialog-commodities.c
===================================================================
--- gnucash/branches/register-rewrite/src/gnome/dialog-commodities.c	2006-05-31 04:07:31 UTC (rev 14280)
+++ gnucash/branches/register-rewrite/src/gnome/dialog-commodities.c	2006-05-31 04:30:18 UTC (rev 14281)
@@ -178,7 +178,6 @@
     for (node = prices; node; node = node->next)
       gnc_pricedb_remove_price(pdb, node->data);
 
-    gnc_commodity_table_remove (ct, commodity);
     gnc_commodity_destroy (commodity);
     commodity = NULL;
   }

Modified: gnucash/branches/register-rewrite/src/gnome-utils/dialog-commodity.c
===================================================================
--- gnucash/branches/register-rewrite/src/gnome-utils/dialog-commodity.c	2006-05-31 04:07:31 UTC (rev 14280)
+++ gnucash/branches/register-rewrite/src/gnome-utils/dialog-commodity.c	2006-05-31 04:30:18 UTC (rev 14281)
@@ -1204,9 +1204,6 @@
     } else {
       c = w->edit_commodity;
       gnc_commodity_begin_edit(c);
-
-      gnc_commodity_table_remove (gnc_get_current_commodities(), c);
-
       gnc_commodity_set_fullname (c, fullname);
       gnc_commodity_set_mnemonic (c, mnemonic);
       gnc_commodity_set_namespace (c, namespace);
@@ -1229,9 +1226,6 @@
     string = gnc_timezone_menu_position_to_string(selection);
     gnc_commodity_set_quote_tz(c, string);
     gnc_commodity_commit_edit(c);
-
-    /* remember the commodity */
-    c = gnc_commodity_table_insert(gnc_get_current_commodities(), c);
   }
   else {
     gnc_warning_dialog(w->dialog,

Modified: gnucash/branches/register-rewrite/src/import-export/binary-import/druid-commodity.c
===================================================================
--- gnucash/branches/register-rewrite/src/import-export/binary-import/druid-commodity.c	2006-05-31 04:07:31 UTC (rev 14280)
+++ gnucash/branches/register-rewrite/src/import-export/binary-import/druid-commodity.c	2006-05-31 04:30:18 UTC (rev 14281)
@@ -152,13 +152,13 @@
 
   d->is_modal = FALSE;
 
-  glade_xml_signal_connect_data
-    (xml, "gnc_ui_commodity_druid_cancel_cb",
-     G_CALLBACK (gnc_ui_commodity_druid_cancel_cb), d);
+  glade_xml_signal_connect_data(
+      xml, "gnc_ui_commodity_druid_cancel_cb",
+      G_CALLBACK (gnc_ui_commodity_druid_cancel_cb), d);
 
-  glade_xml_signal_connect_data
-    (xml, "gnc_ui_commodity_druid_finish_cb",
-     G_CALLBACK (gnc_ui_commodity_druid_finish_cb), d);
+  glade_xml_signal_connect_data(
+      xml, "gnc_ui_commodity_druid_finish_cb",
+      G_CALLBACK (gnc_ui_commodity_druid_finish_cb), d);
 
   d->new_map = g_hash_table_new(g_str_hash, g_str_equal);
   d->old_map = g_hash_table_new(g_str_hash, g_str_equal);
@@ -168,7 +168,7 @@
 
   /* make a new list with the (saved) old mnemonic and the 
    * new currency. */
-  for(l=orphans; l; l=l->next) {
+  for (l = orphans; l; l = l->next) {
     lost = (gnc_commodity *)l->data;
     
     /* if the mnemonic is an ISO-4217 currency, use that as 
@@ -178,7 +178,7 @@
                                        gnc_commodity_get_mnemonic(lost));
 
     /* otherwise, guess that it's a NASDAQ security. */
-    if(!found) {
+    if (!found) {
       found = gnc_commodity_new(book, gnc_commodity_get_mnemonic(lost),
                                 GNC_COMMODITY_NS_NASDAQ,
                                 gnc_commodity_get_mnemonic(lost),
@@ -448,10 +448,6 @@
     return;
   }
 
-  /* key is the old mnemonic, value is a pointer to the gnc_commodity 
-   * structure. */
-  comm = gnc_commodity_table_insert(gnc_get_current_commodities(), comm);
-
   /* s/old commodity/new commodity/g  in the pricedb */
   gnc_pricedb_substitute_commodity(gnc_book_get_pricedb(book),
 				   old_comm,

Modified: gnucash/branches/register-rewrite/src/import-export/qif-import/druid-qif-import.c
===================================================================
--- gnucash/branches/register-rewrite/src/import-export/qif-import/druid-qif-import.c	2006-05-31 04:07:31 UTC (rev 14280)
+++ gnucash/branches/register-rewrite/src/import-export/qif-import/druid-qif-import.c	2006-05-31 04:30:18 UTC (rev 14281)
@@ -1121,7 +1121,6 @@
   GList        * pageptr;
   Transaction  * gnc_xtn;
   Split        * gnc_split;
-  gnc_commodity * old_commodity;
 
   const char * mnemonic = NULL; 
   const char * namespace = NULL;
@@ -1148,13 +1147,6 @@
     gnc_commodity_set_namespace(page->commodity, namespace);
     gnc_commodity_set_fullname(page->commodity, fullname);
     gnc_commodity_set_mnemonic(page->commodity, mnemonic);
-
-    old_commodity = page->commodity;
-    page->commodity = gnc_commodity_table_insert(gnc_get_current_commodities(),
-                                                 page->commodity);
-    if (old_commodity != page->commodity) {
-	scm_hash_remove_x(wind->stock_hash, scm_makfrom0str(fullname));
-    }
   }
 
   /* call a scheme function to do the work.  The return value is an



More information about the gnucash-changes mailing list