diff --git a/src/engine/gnc-pricedb.c b/src/engine/gnc-pricedb.c index 64d2afa955..df89f68a18 100644 --- a/src/engine/gnc-pricedb.c +++ b/src/engine/gnc-pricedb.c @@ -1056,18 +1056,6 @@ gnc_pricedb_equal (GNCPriceDB *db1, GNCPriceDB *db2) return equal_data.equal; } -static gboolean -insert_or_replace_price(GNCPriceDB *db, GNCPrice *p) -{ - GNCPrice *old_price = gnc_pricedb_lookup_day (db, p->commodity, - p->currency, p->tmspec); - if (old_price == NULL) - return TRUE; - if (p->source < old_price->source) - return TRUE; - return FALSE; - -} /* ==================================================================== */ /* The add_price() function is a utility that only manages the * dual hash table instertion */ @@ -1081,6 +1069,7 @@ add_price(GNCPriceDB *db, GNCPrice *p) gnc_commodity *commodity; gnc_commodity *currency; GHashTable *currency_hash; + GNCPrice *old_price; if (!db || !p) return FALSE; ENTER ("db=%p, pr=%p dirty=%d destroying=%d", @@ -1114,12 +1103,6 @@ add_price(GNCPriceDB *db, GNCPrice *p) return FALSE; } - if (!insert_or_replace_price(db, p)) - { - LEAVE("A better price already exists"); - return FALSE; - } - currency_hash = g_hash_table_lookup(db->commodity_hash, commodity); if (!currency_hash) { @@ -1133,14 +1116,32 @@ add_price(GNCPriceDB *db, GNCPrice *p) LEAVE ("gnc_price_list_insert failed"); return FALSE; } + if (!price_list) { LEAVE (" no price list"); return FALSE; } +/* Check for an existing price on the same day. If there is no existing price, + * add this one. If this price is of equal or better precedence than the old + * one, copy this one over the old one. + */ + old_price = gnc_pricedb_lookup_day (db, p->commodity, p->currency, + p->tmspec); + if (!db->bulk_update && old_price != NULL) + { + if (p->source > old_price->source) + { + gnc_price_unref(p); + LEAVE ("Better price already in DB."); + return FALSE; + } + gnc_pricedb_remove_price(db, old_price); + } g_hash_table_insert(currency_hash, currency, price_list); p->db = db; + qof_event_gen (&p->inst, QOF_EVENT_ADD, NULL); LEAVE ("db=%p, pr=%p dirty=%d dextroying=%d commodity=%s/%s currency_hash=%p", diff --git a/src/gnome-utils/dialog-commodity.c b/src/gnome-utils/dialog-commodity.c index 2ebe179b2d..ca3c564921 100644 --- a/src/gnome-utils/dialog-commodity.c +++ b/src/gnome-utils/dialog-commodity.c @@ -644,9 +644,8 @@ gnc_ui_update_namespace_picker (GtkWidget *cbwe, { GtkComboBox *combo_box; GtkTreeModel *model; - GtkTreeIter iter; + GtkTreeIter iter, match; GList *namespaces, *node; - gint current = 0, match = 0; g_return_if_fail(GTK_IS_COMBO_BOX (cbwe)); @@ -654,7 +653,8 @@ gnc_ui_update_namespace_picker (GtkWidget *cbwe, combo_box = GTK_COMBO_BOX(cbwe); model = gtk_combo_box_get_model(combo_box); gtk_list_store_clear(GTK_LIST_STORE(model)); - gtk_combo_box_set_active(combo_box, -1); + gtk_tree_model_get_iter_first(model, &match); + gtk_combo_box_set_active_iter(combo_box, &match); /* fetch a list of the namespaces */ switch (mode) @@ -698,11 +698,10 @@ gnc_ui_update_namespace_picker (GtkWidget *cbwe, } if (init_string && (g_utf8_collate(node->data, init_string) == 0)) - match = current; - current++; + match = iter; } - gtk_combo_box_set_active(combo_box, match); + gtk_combo_box_set_active_iter(combo_box, &match); g_list_free(namespaces); } diff --git a/src/report/report-system/html-document.scm b/src/report/report-system/html-document.scm index 9b63d09e2c..4bfcb89215 100644 --- a/src/report/report-system/html-document.scm +++ b/src/report/report-system/html-document.scm @@ -158,9 +158,8 @@ ;;./share/gnucash/scm/gnucash/report/taxinvoice.eguile.scm: ;;./share/gnucash/scm/gnucash/report/balsheet-eg.eguile.scm: - ;; Validate against XHTML 1.0 Transitional - (push "") - (push "\n") + ;; Validate against HTML4 Transitional: + (push "") (push "\n") (push "\n") (if css?