[Gnucash-changes] r14252 - gnucash/branches/register-rewrite/src -
Factor a 1.8 compatibility hack out of the normal calling
sequence into a
Chris Shoemaker
chris at cvs.gnucash.org
Mon May 29 22:06:12 EDT 2006
Author: chris
Date: 2006-05-29 22:06:12 -0400 (Mon, 29 May 2006)
New Revision: 14252
Trac: http://svn.gnucash.org/trac/changeset/14252
Modified:
gnucash/branches/register-rewrite/src/backend/file/gnc-account-xml-v2.c
gnucash/branches/register-rewrite/src/backend/postgres/account.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
Log:
Factor a 1.8 compatibility hack out of the normal calling sequence into a
stand-alone function. This will allow us to mark the Account's commodity
as const.
Modified: gnucash/branches/register-rewrite/src/backend/file/gnc-account-xml-v2.c
===================================================================
--- gnucash/branches/register-rewrite/src/backend/file/gnc-account-xml-v2.c 2006-05-29 22:07:10 UTC (rev 14251)
+++ gnucash/branches/register-rewrite/src/backend/file/gnc-account-xml-v2.c 2006-05-30 02:06:12 UTC (rev 14252)
@@ -249,6 +249,7 @@
ref = dom_tree_to_commodity_ref_no_engine(node, pdata->book);
xaccAccountSetCommodity(pdata->account, ref);
+ gnc_commodity_apply_hack_for_1_8(ref);
return TRUE;
}
@@ -309,6 +310,7 @@
if (!xaccAccountGetCommodity(pdata->account)) {
ref = dom_tree_to_commodity_ref_no_engine(node, pdata->book);
xaccAccountSetCommodity(pdata->account, ref);
+ gnc_commodity_apply_hack_for_1_8(ref);
}
return TRUE;
Modified: gnucash/branches/register-rewrite/src/backend/postgres/account.c
===================================================================
--- gnucash/branches/register-rewrite/src/backend/postgres/account.c 2006-05-29 22:07:10 UTC (rev 14251)
+++ gnucash/branches/register-rewrite/src/backend/postgres/account.c 2006-05-30 02:06:12 UTC (rev 14252)
@@ -307,8 +307,10 @@
xaccAccountSetDescription(acc, DB_GET_VAL("description",j));
xaccAccountSetCode(acc, DB_GET_VAL("accountCode",j));
xaccAccountSetType(acc, xaccAccountStringToEnum(DB_GET_VAL("type",j)));
- if (commodity)
+ if (commodity) {
xaccAccountSetCommodity(acc, commodity);
+ gnc_commodity_apply_hack_for_1_8(commodity);
+ }
xaccAccountSetVersion(acc, atoi(DB_GET_VAL("version",j)));
acc->idata = atoi(DB_GET_VAL("iguid",j));
@@ -380,6 +382,7 @@
if (commodity)
{
xaccAccountSetCommodity (ri->account, commodity);
+ gnc_commodity_apply_hack_for_1_8(commodity);
}
else
{
Modified: gnucash/branches/register-rewrite/src/engine/Account.c
===================================================================
--- gnucash/branches/register-rewrite/src/engine/Account.c 2006-05-29 22:07:10 UTC (rev 14251)
+++ gnucash/branches/register-rewrite/src/engine/Account.c 2006-05-30 02:06:12 UTC (rev 14252)
@@ -1165,13 +1165,6 @@
acc->balance_dirty = TRUE;
mark_account (acc);
- if (gnc_commodity_is_iso(com)) {
- /* compatability hack - Gnucash 1.8 gets currency quotes when a
- non-default currency is assigned to an account. */
- gnc_commodity_set_quote_flag(com, TRUE);
- gnc_commodity_set_quote_source(com,
- gnc_commodity_get_default_quote_source(com));
- }
xaccAccountCommitEdit(acc);
}
Modified: gnucash/branches/register-rewrite/src/engine/gnc-commodity.c
===================================================================
--- gnucash/branches/register-rewrite/src/engine/gnc-commodity.c 2006-05-29 22:07:10 UTC (rev 14251)
+++ gnucash/branches/register-rewrite/src/engine/gnc-commodity.c 2006-05-30 02:06:12 UTC (rev 14252)
@@ -1771,6 +1771,24 @@
return TRUE;
}
+/* This hack deals with the movement of the "get_quote" flag from
+ Account to gnc_commodity. It only needs to be applied to
+ commodities used for accounts in 1.8 data files.
+
+ References: http://svn.gnucash.org/trac/changeset/8292
+ http://bugzilla.gnome.org/show_bug.cgi?id=333572 */
+void
+gnc_commodity_apply_hack_for_1_8(gnc_commodity *com)
+{
+ if (gnc_commodity_is_iso(com)) {
+ /* compatability hack - Gnucash 1.8 gets currency quotes when a
+ non-default currency is assigned to an account. */
+ gnc_commodity_set_quote_flag(com, TRUE);
+ gnc_commodity_set_quote_source(com,
+ gnc_commodity_get_default_quote_source(com));
+ }
+}
+
/********************************************************************
********************************************************************/
/* QofObject function implementation and registration */
Modified: gnucash/branches/register-rewrite/src/engine/gnc-commodity.h
===================================================================
--- gnucash/branches/register-rewrite/src/engine/gnc-commodity.h 2006-05-29 22:07:10 UTC (rev 14251)
+++ gnucash/branches/register-rewrite/src/engine/gnc-commodity.h 2006-05-30 02:06:12 UTC (rev 14252)
@@ -884,6 +884,8 @@
void gnc_commodity_begin_edit (gnc_commodity *cm);
void gnc_commodity_commit_edit (gnc_commodity *cm);
+
+void gnc_commodity_apply_hack_for_1_8(gnc_commodity *cm);
/** @} */
More information about the gnucash-changes
mailing list