gnucash maint: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Tue Sep 14 21:24:20 EDT 2021
Updated via https://github.com/Gnucash/gnucash/commit/d290c3c4 (commit)
via https://github.com/Gnucash/gnucash/commit/37444374 (commit)
from https://github.com/Gnucash/gnucash/commit/1d898319 (commit)
commit d290c3c45d0dbcebfa8c953b04bad01633bcffcf
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Wed Sep 15 09:05:39 2021 +0800
[account.cpp] deprecate old dxacc* functions
diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp
index f6ac68f38..cad33174d 100644
--- a/libgnucash/engine/Account.cpp
+++ b/libgnucash/engine/Account.cpp
@@ -2715,6 +2715,7 @@ DxaccAccountSetCurrency (Account * acc, gnc_commodity * currency)
gnc_commodity *commodity;
gnc_commodity_table *table;
+ PWARN ("this function is deprecated and will be removed in 5.x");
if ((!acc) || (!currency)) return;
g_value_init (&v, G_TYPE_STRING);
g_value_set_string (&v, s);
@@ -3373,6 +3374,7 @@ DxaccAccountGetCurrency (const Account *acc)
const char *s = NULL;
gnc_commodity_table *table;
+ PWARN ("this function is deprecated and will be removed in 5.x");
if (!acc) return NULL;
qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v, {"old-currency"});
if (G_VALUE_HOLDS_STRING (&v))
@@ -4983,6 +4985,7 @@ xaccAccountGainsAccount (Account *acc, gnc_commodity *curr)
void
dxaccAccountSetPriceSrc(Account *acc, const char *src)
{
+ PWARN ("this function is deprecated and will be removed in 5.x");
if (!acc) return;
if (xaccAccountIsPriced(acc))
@@ -5011,6 +5014,7 @@ const char*
dxaccAccountGetPriceSrc(const Account *acc)
{
GValue v = G_VALUE_INIT;
+ PWARN ("this function is deprecated and will be removed in 5.x");
if (!acc) return NULL;
if (!xaccAccountIsPriced(acc)) return NULL;
@@ -5026,6 +5030,7 @@ void
dxaccAccountSetQuoteTZ(Account *acc, const char *tz)
{
GValue v = G_VALUE_INIT;
+ PWARN ("this function is deprecated and will be removed in 5.x");
if (!acc) return;
if (!xaccAccountIsPriced(acc)) return;
xaccAccountBeginEdit(acc);
@@ -5043,6 +5048,7 @@ const char*
dxaccAccountGetQuoteTZ(const Account *acc)
{
GValue v = G_VALUE_INIT;
+ PWARN ("this function is deprecated and will be removed in 5.x");
if (!acc) return NULL;
if (!xaccAccountIsPriced(acc)) return NULL;
qof_instance_get_path_kvp (QOF_INSTANCE (acc), &v, {"old-quote-tz"});
commit 374443747d33aad60326a748484dfd07ca2e4fcb
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Tue Sep 14 07:23:22 2021 +0800
[account.cpp] new static: get/set_kvp_string_path
exactly the same as set_kvp_string_tag but will accept the full kvp
path.
diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp
index 39cb5b88e..f6ac68f38 100644
--- a/libgnucash/engine/Account.cpp
+++ b/libgnucash/engine/Account.cpp
@@ -2486,7 +2486,8 @@ stripdup_or_null (const char *value)
// note the *value argument is expected to be either a strstripped
// char* or nullptr, as returned by stripdup_or_null above.
static void
-set_kvp_string_tag (Account *acc, const char *tag, const char *value)
+set_kvp_string_path (Account *acc, std::vector<std::string> const & path,
+ const char *value)
{
g_return_if_fail(GNC_IS_ACCOUNT(acc));
@@ -2496,28 +2497,40 @@ set_kvp_string_tag (Account *acc, const char *tag, const char *value)
GValue v = G_VALUE_INIT;
g_value_init (&v, G_TYPE_STRING);
g_value_set_string (&v, value);
- qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, {tag});
+ qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, path);
g_value_unset (&v);
}
else
{
- qof_instance_set_path_kvp (QOF_INSTANCE (acc), NULL, {tag});
+ qof_instance_set_path_kvp (QOF_INSTANCE (acc), NULL, path);
}
mark_account (acc);
xaccAccountCommitEdit(acc);
}
+static void
+set_kvp_string_tag (Account *acc, const char *tag, const char *value)
+{
+ set_kvp_string_path (acc, {tag}, value);
+}
+
static char*
-get_kvp_string_tag (const Account *acc, const char *tag)
+get_kvp_string_path (const Account *acc, std::vector<std::string> const & path)
{
GValue v = G_VALUE_INIT;
- if (acc == NULL || tag == NULL) return NULL;
- qof_instance_get_path_kvp (QOF_INSTANCE (acc), &v, {tag});
+ if (acc == NULL) return NULL; // how to check path is valid??
+ qof_instance_get_path_kvp (QOF_INSTANCE (acc), &v, path);
auto retval = G_VALUE_HOLDS_STRING (&v) ? g_value_dup_string (&v) : NULL;
g_value_unset (&v);
return retval;
}
+static char*
+get_kvp_string_tag (const Account *acc, const char *tag)
+{
+ return get_kvp_string_path (acc, {tag});
+}
+
void
xaccAccountSetColor (Account *acc, const char *str)
{
Summary of changes:
libgnucash/engine/Account.cpp | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)
More information about the gnucash-changes
mailing list