mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
* src/scm/iso-4217-currencies.scm: remove duplicate currency
* src/engine/sixtp-dom-parsers.c (dom_tree_to_commodity_ref): use gnc_commodity_destroy, not g_free. * src/guile/gnc.gwp: fix for new commodity insert * src/gnome/druid-qif-import.c: fix for new commodity insert * src/gnome/dialog-commodity.c: check for existing commodity. fix for new commodity insert. * src/engine/io-gncbin-r.c: fix for new commodity insert * src/gnome/druid-commodity.c: fix for new commodity insert * src/engine/gnc-commodity.c: change commodity insert semantics to use an existing commodity if present. Remove gnc_commodity_table_remove(). It wasn't used and was a mem leak. * src/engine/Commodity-xml-parser-v1.c (commodity_restore_end_handler): use gnc_commodity_destroy, not just g_free. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3754 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
802b9216fc
commit
b6dc29d3ce
26
ChangeLog
26
ChangeLog
@ -1,3 +1,29 @@
|
||||
2001-03-06 Dave Peticolas <dave@krondo.com>
|
||||
|
||||
* src/scm/iso-4217-currencies.scm: remove duplicate currency
|
||||
|
||||
* src/engine/sixtp-dom-parsers.c (dom_tree_to_commodity_ref): use
|
||||
gnc_commodity_destroy, not g_free.
|
||||
|
||||
* src/guile/gnc.gwp: fix for new commodity insert
|
||||
|
||||
* src/gnome/druid-qif-import.c: fix for new commodity insert
|
||||
|
||||
* src/gnome/dialog-commodity.c: check for existing commodity.
|
||||
fix for new commodity insert.
|
||||
|
||||
* src/engine/io-gncbin-r.c: fix for new commodity insert
|
||||
|
||||
* src/gnome/druid-commodity.c: fix for new commodity insert
|
||||
|
||||
* src/engine/gnc-commodity.c: change commodity insert semantics to
|
||||
use an existing commodity if present. Remove
|
||||
gnc_commodity_table_remove(). It wasn't used and was a mem leak.
|
||||
|
||||
* src/engine/Commodity-xml-parser-v1.c
|
||||
(commodity_restore_end_handler): use gnc_commodity_destroy,
|
||||
not just g_free.
|
||||
|
||||
2001-03-05 Dave Peticolas <dave@krondo.com>
|
||||
|
||||
* src/register/gnome/gnucash-item-edit.{ch}: improve horizontal
|
||||
|
@ -170,7 +170,7 @@ commodity_restore_end_handler(gpointer data_for_children,
|
||||
g_free(cpi->xcode);
|
||||
g_free(cpi);
|
||||
|
||||
if(!ok) g_free(comm);
|
||||
if(!ok) gnc_commodity_destroy(comm);
|
||||
|
||||
return(ok);
|
||||
}
|
||||
|
@ -323,12 +323,12 @@ int xaccAccountStagedTransactionTraversal(Account *a,
|
||||
|
||||
/* Traverse all of the transactions in the given account group.
|
||||
Continue processing IFF proc does not return FALSE. This function
|
||||
does not descend recursively to traverse transactions in the
|
||||
will descend recursively to traverse transactions in the
|
||||
children of the accounts in the group.
|
||||
|
||||
Proc will be called exactly once for each transaction that is
|
||||
pointed to by at least one split in an account in the account
|
||||
group.
|
||||
pointed to by at least one split in any account in the hierarchy
|
||||
topped by AccountGroup g.
|
||||
|
||||
Note too, that if you call this function on two separate account
|
||||
groups and those accounts groups share transactions, proc will be
|
||||
|
@ -22,6 +22,9 @@
|
||||
*******************************************************************/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
@ -200,6 +203,7 @@ gnc_commodity_get_fraction(const gnc_commodity * cm) {
|
||||
void
|
||||
gnc_commodity_set_mnemonic(gnc_commodity * cm, const char * mnemonic) {
|
||||
if(!cm) return;
|
||||
if(cm->mnemonic == mnemonic) return;
|
||||
|
||||
g_free(cm->mnemonic);
|
||||
cm->mnemonic = g_strdup(mnemonic);
|
||||
@ -215,6 +219,7 @@ gnc_commodity_set_mnemonic(gnc_commodity * cm, const char * mnemonic) {
|
||||
void
|
||||
gnc_commodity_set_namespace(gnc_commodity * cm, const char * namespace) {
|
||||
if(!cm) return;
|
||||
if(cm->namespace == namespace) return;
|
||||
|
||||
g_free(cm->namespace);
|
||||
cm->namespace = g_strdup(namespace);
|
||||
@ -230,6 +235,7 @@ gnc_commodity_set_namespace(gnc_commodity * cm, const char * namespace) {
|
||||
void
|
||||
gnc_commodity_set_fullname(gnc_commodity * cm, const char * fullname) {
|
||||
if(!cm) return;
|
||||
if(cm->fullname == fullname) return;
|
||||
|
||||
g_free(cm->fullname);
|
||||
cm->fullname = g_strdup(fullname);
|
||||
@ -245,6 +251,7 @@ void
|
||||
gnc_commodity_set_exchange_code(gnc_commodity * cm,
|
||||
const char * exchange_code) {
|
||||
if(!cm) return;
|
||||
if(cm->exchange_code == exchange_code) return;
|
||||
|
||||
g_free(cm->exchange_code);
|
||||
cm->exchange_code = g_strdup(exchange_code);
|
||||
@ -268,12 +275,8 @@ gnc_commodity_set_fraction(gnc_commodity * cm, int fraction) {
|
||||
|
||||
gboolean
|
||||
gnc_commodity_equiv(const gnc_commodity * a, const gnc_commodity * b) {
|
||||
/* fprintf(stderr, "CmpCmod %p ?= %p\n", a, b); */
|
||||
if(a == b) return TRUE;
|
||||
if(!a || !b) return FALSE;
|
||||
/* fprintf(stderr, "CmpCmod %s:%s ?= %s:%s\n",
|
||||
a->namespace, a->mnemonic,
|
||||
b->namespace, b->mnemonic); */
|
||||
if(safe_strcmp(a->namespace, b->namespace) != 0) return FALSE;
|
||||
if(safe_strcmp(a->mnemonic, b->mnemonic) != 0) return FALSE;
|
||||
return TRUE;
|
||||
@ -351,10 +354,27 @@ gnc_commodity_table_find_full(const gnc_commodity_table * table,
|
||||
* add a commodity to the table.
|
||||
********************************************************************/
|
||||
|
||||
void
|
||||
gnc_commodity *
|
||||
gnc_commodity_table_insert(gnc_commodity_table * table,
|
||||
const gnc_commodity * comm) {
|
||||
gnc_commodity * comm) {
|
||||
gnc_commodity_namespace * nsp = NULL;
|
||||
gnc_commodity *c;
|
||||
|
||||
if (!table) return NULL;
|
||||
if (!comm) return NULL;
|
||||
|
||||
c = gnc_commodity_table_lookup (table, comm->namespace, comm->mnemonic);
|
||||
|
||||
if (c) {
|
||||
gnc_commodity_set_fullname (c, gnc_commodity_get_fullname (comm));
|
||||
gnc_commodity_set_fraction (c, gnc_commodity_get_fraction (comm));
|
||||
gnc_commodity_set_exchange_code (c,
|
||||
gnc_commodity_get_exchange_code (comm));
|
||||
|
||||
gnc_commodity_destroy (comm);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
nsp = g_hash_table_lookup(table->table, (gpointer)(comm->namespace));
|
||||
|
||||
@ -366,26 +386,11 @@ gnc_commodity_table_insert(gnc_commodity_table * table,
|
||||
(gpointer)nsp);
|
||||
}
|
||||
|
||||
return g_hash_table_insert(nsp->table,
|
||||
(gpointer)g_strdup(comm->mnemonic),
|
||||
(gpointer)comm);
|
||||
}
|
||||
g_hash_table_insert(nsp->table,
|
||||
(gpointer)g_strdup(comm->mnemonic),
|
||||
(gpointer)comm);
|
||||
|
||||
/********************************************************************
|
||||
* gnc_commodity_table_remove
|
||||
* remove a commodity from the table (just unmaps it)
|
||||
********************************************************************/
|
||||
|
||||
void
|
||||
gnc_commodity_table_remove(gnc_commodity_table * table,
|
||||
const gnc_commodity * comm) {
|
||||
gnc_commodity_namespace * nsp = NULL;
|
||||
|
||||
nsp = g_hash_table_lookup(table->table, (gpointer)(comm->namespace));
|
||||
|
||||
if(nsp) {
|
||||
g_hash_table_remove(nsp->table, (gpointer)comm->mnemonic);
|
||||
}
|
||||
return comm;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
|
@ -75,10 +75,8 @@ gnc_commodity * gnc_commodity_table_lookup(const gnc_commodity_table * table,
|
||||
gnc_commodity * gnc_commodity_table_find_full(const gnc_commodity_table * t,
|
||||
const char * namespace,
|
||||
const char * fullname);
|
||||
void gnc_commodity_table_insert(gnc_commodity_table * table,
|
||||
const gnc_commodity * comm);
|
||||
void gnc_commodity_table_remove(gnc_commodity_table * table,
|
||||
const gnc_commodity * comm);
|
||||
gnc_commodity * gnc_commodity_table_insert(gnc_commodity_table * table,
|
||||
gnc_commodity * comm);
|
||||
|
||||
int gnc_commodity_table_has_namespace(const gnc_commodity_table * t,
|
||||
const char * namespace);
|
||||
|
@ -377,8 +377,7 @@ gnc_commodity_import_legacy(const char * currency_name) {
|
||||
old = gnc_commodity_new(currency_name,
|
||||
GNC_COMMODITY_NS_LEGACY, currency_name,
|
||||
0, 100000);
|
||||
gnc_commodity_table_insert(gnc_engine_commodities(),
|
||||
old);
|
||||
old = gnc_commodity_table_insert(gnc_engine_commodities(), old);
|
||||
}
|
||||
return old;
|
||||
}
|
||||
|
@ -617,21 +617,22 @@ dom_tree_to_commodity_ref_no_engine(xmlNodePtr node)
|
||||
c = gnc_commodity_new(NULL, space_str, id_str, NULL, 0);
|
||||
}
|
||||
|
||||
if(space_str) g_free(space_str);
|
||||
if(id_str) g_free(id_str);
|
||||
g_free(space_str);
|
||||
g_free(id_str);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
gnc_commodity*
|
||||
dom_tree_to_commodity_ref(xmlNodePtr node)
|
||||
{
|
||||
gnc_commodity* daref;
|
||||
gnc_commodity *daref;
|
||||
gnc_commodity *ret;
|
||||
|
||||
daref = dom_tree_to_commodity_ref_no_engine(node);
|
||||
ret = associate_commodity_ref_with_engine_commodity(daref);
|
||||
|
||||
g_free(daref);
|
||||
gnc_commodity_destroy(daref);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -457,14 +457,23 @@ gnc_ui_new_commodity_ok_cb(GtkButton * button,
|
||||
if(fullname && fullname[0] &&
|
||||
namespace && namespace[0] &&
|
||||
mnemonic && mnemonic[0]) {
|
||||
c = gnc_commodity_table_lookup (gnc_engine_commodities(),
|
||||
namespace, mnemonic);
|
||||
|
||||
if (c) {
|
||||
gnc_warning_dialog_parented (dialog,
|
||||
_("That commodity already exists."));
|
||||
return;
|
||||
}
|
||||
|
||||
c = gnc_commodity_new(fullname, namespace, mnemonic,
|
||||
gtk_entry_get_text
|
||||
(GTK_ENTRY(w->code_entry)),
|
||||
gtk_spin_button_get_value_as_int
|
||||
(GTK_SPIN_BUTTON(w->fraction_spinbutton)));
|
||||
|
||||
|
||||
/* remember the commodity */
|
||||
gnc_commodity_table_insert(gnc_engine_commodities(), c);
|
||||
c = gnc_commodity_table_insert(gnc_engine_commodities(), c);
|
||||
|
||||
/* if there's a callback (generally to fill in some fields with
|
||||
* info about the commodity) call it */
|
||||
@ -476,9 +485,10 @@ gnc_ui_new_commodity_ok_cb(GtkButton * button,
|
||||
gnc_ui_new_commodity_destroy(w);
|
||||
}
|
||||
else {
|
||||
gnc_warning_dialog(_("You must enter a non-empty \"Full name\", "
|
||||
"\"Symbol/abbreviation\",\n"
|
||||
"and \"Type\" for the commodity."));
|
||||
gnc_warning_dialog_parented(dialog,
|
||||
_("You must enter a non-empty \"Full name\", "
|
||||
"\"Symbol/abbreviation\",\n"
|
||||
"and \"Type\" for the commodity."));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -417,7 +417,7 @@ finish_helper(gpointer key, gpointer value, gpointer data) {
|
||||
|
||||
/* key is the old mnemonic, value is a pointer to the gnc_commodity
|
||||
* structure. */
|
||||
gnc_commodity_table_insert(gnc_engine_commodities(), comm);
|
||||
comm = gnc_commodity_table_insert(gnc_engine_commodities(), comm);
|
||||
|
||||
/* s/old commodity/new commodity/g in the pricedb */
|
||||
gnc_pricedb_substitute_commodity(gnc_book_get_pricedb(book),
|
||||
|
@ -1207,7 +1207,8 @@ gnc_ui_qif_import_convert(QIFImportWindow * wind) {
|
||||
gnc_commodity_set_fullname(page->commodity, fullname);
|
||||
gnc_commodity_set_mnemonic(page->commodity, mnemonic);
|
||||
|
||||
gnc_commodity_table_insert(gnc_engine_commodities(), page->commodity);
|
||||
page->commodity = gnc_commodity_table_insert(gnc_engine_commodities(),
|
||||
page->commodity);
|
||||
}
|
||||
|
||||
/* call a scheme function to do the work. The return value is an
|
||||
|
@ -59,7 +59,6 @@
|
||||
( "Fiji Dollar" "dollar" "cent" "ISO4217" "FJD" "242" 100 100 )
|
||||
( "Finnish Markka" "markka" "penni" "ISO4217" "FIM" "246" 100 100)
|
||||
( "French Franc" "franc" "centime" "ISO4217" "FRF" "250" 100 100 )
|
||||
( "Gabon Franc" "franc" "centime" "ISO4217" "XAF" "950" 100 100 )
|
||||
( "Gambian Dalasi" "dalasi" "butut" "ISO4217" "GMD" "270" 100 100 )
|
||||
( "German Mark" "deutschemark" "pfennig" "ISO4217" "DEM" "280" 100 100 )
|
||||
( "Ghanaian Cedi" "cedi" "psewa" "ISO4217" "GHC" "288" 100 100 )
|
||||
|
Loading…
Reference in New Issue
Block a user