mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[account.cpp] GValue containing string must be unset
already have comprehensive tests in 15852031d
This commit is contained in:
parent
c8a53c54f2
commit
86cf327f09
@ -325,6 +325,9 @@ gnc_account_init(Account* acc)
|
|||||||
priv->starting_reconciled_balance = gnc_numeric_zero();
|
priv->starting_reconciled_balance = gnc_numeric_zero();
|
||||||
priv->balance_dirty = FALSE;
|
priv->balance_dirty = FALSE;
|
||||||
|
|
||||||
|
priv->last_num = (char*) is_unset;
|
||||||
|
priv->tax_us_code = (char*) is_unset;
|
||||||
|
priv->tax_us_pns = (char*) is_unset;
|
||||||
priv->color = (char*) is_unset;
|
priv->color = (char*) is_unset;
|
||||||
priv->sort_order = (char*) is_unset;
|
priv->sort_order = (char*) is_unset;
|
||||||
priv->notes = (char*) is_unset;
|
priv->notes = (char*) is_unset;
|
||||||
@ -1374,6 +1377,12 @@ xaccFreeAccount (Account *acc)
|
|||||||
qof_string_cache_remove(priv->description);
|
qof_string_cache_remove(priv->description);
|
||||||
priv->accountName = priv->accountCode = priv->description = nullptr;
|
priv->accountName = priv->accountCode = priv->description = nullptr;
|
||||||
|
|
||||||
|
if (priv->last_num != is_unset)
|
||||||
|
g_free (priv->last_num);
|
||||||
|
if (priv->tax_us_code != is_unset)
|
||||||
|
g_free (priv->tax_us_code);
|
||||||
|
if (priv->tax_us_pns != is_unset)
|
||||||
|
g_free (priv->tax_us_pns);
|
||||||
if (priv->color != is_unset)
|
if (priv->color != is_unset)
|
||||||
g_free (priv->color);
|
g_free (priv->color);
|
||||||
if (priv->sort_order != is_unset)
|
if (priv->sort_order != is_unset)
|
||||||
@ -1386,6 +1395,9 @@ xaccFreeAccount (Account *acc)
|
|||||||
/* zero out values, just in case stray
|
/* zero out values, just in case stray
|
||||||
* pointers are pointing here. */
|
* pointers are pointing here. */
|
||||||
|
|
||||||
|
priv->last_num = nullptr;
|
||||||
|
priv->tax_us_code = nullptr;
|
||||||
|
priv->tax_us_pns = nullptr;
|
||||||
priv->color == nullptr;
|
priv->color == nullptr;
|
||||||
priv->sort_order == nullptr;
|
priv->sort_order == nullptr;
|
||||||
priv->notes == nullptr;
|
priv->notes == nullptr;
|
||||||
@ -4098,49 +4110,39 @@ xaccAccountSetTaxRelated (Account *acc, gboolean tax_related)
|
|||||||
const char *
|
const char *
|
||||||
xaccAccountGetTaxUSCode (const Account *acc)
|
xaccAccountGetTaxUSCode (const Account *acc)
|
||||||
{
|
{
|
||||||
GValue v = G_VALUE_INIT;
|
auto priv = GET_PRIVATE (acc);
|
||||||
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
|
if (priv->tax_us_code == is_unset)
|
||||||
qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v, {"tax-US", "code"});
|
priv->tax_us_code = get_kvp_string_path (acc, {"tax-US", "code"});
|
||||||
return G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL;
|
return priv->tax_us_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xaccAccountSetTaxUSCode (Account *acc, const char *code)
|
xaccAccountSetTaxUSCode (Account *acc, const char *code)
|
||||||
{
|
{
|
||||||
GValue v = G_VALUE_INIT;
|
auto priv = GET_PRIVATE (acc);
|
||||||
g_return_if_fail(GNC_IS_ACCOUNT(acc));
|
if (priv->tax_us_code != is_unset)
|
||||||
|
g_free (priv->tax_us_code);
|
||||||
g_value_init (&v, G_TYPE_STRING);
|
priv->tax_us_code = g_strdup (code);
|
||||||
g_value_set_string (&v, code);
|
set_kvp_string_path (acc, {"tax-US", "code"}, priv->tax_us_code);
|
||||||
xaccAccountBeginEdit (acc);
|
|
||||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, {"tax-US", "code"});
|
|
||||||
mark_account (acc);
|
|
||||||
xaccAccountCommitEdit (acc);
|
|
||||||
g_value_unset (&v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
xaccAccountGetTaxUSPayerNameSource (const Account *acc)
|
xaccAccountGetTaxUSPayerNameSource (const Account *acc)
|
||||||
{
|
{
|
||||||
GValue v = G_VALUE_INIT;
|
auto priv = GET_PRIVATE (acc);
|
||||||
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
|
if (priv->tax_us_pns == is_unset)
|
||||||
qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v, {"tax-US", "payer-name-source"});
|
priv->tax_us_pns = get_kvp_string_path (acc, {"tax-US", "payer-name-source"});
|
||||||
return G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL;
|
return priv->tax_us_pns;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xaccAccountSetTaxUSPayerNameSource (Account *acc, const char *source)
|
xaccAccountSetTaxUSPayerNameSource (Account *acc, const char *source)
|
||||||
{
|
{
|
||||||
GValue v = G_VALUE_INIT;
|
auto priv = GET_PRIVATE (acc);
|
||||||
g_return_if_fail(GNC_IS_ACCOUNT(acc));
|
if (priv->tax_us_pns != is_unset)
|
||||||
|
g_free (priv->tax_us_pns);
|
||||||
g_value_init (&v, G_TYPE_STRING);
|
priv->tax_us_pns = g_strdup (source);
|
||||||
g_value_set_string (&v, source);
|
set_kvp_string_path (acc, {"tax-US", "payer-name-source"}, priv->tax_us_pns);
|
||||||
xaccAccountBeginEdit (acc);
|
|
||||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, {"tax-US", "payer-name-source"});
|
|
||||||
mark_account (acc);
|
|
||||||
xaccAccountCommitEdit (acc);
|
|
||||||
g_value_unset (&v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gint64
|
gint64
|
||||||
@ -4871,10 +4873,10 @@ xaccAccountClearReconcilePostpone (Account *acc)
|
|||||||
const char *
|
const char *
|
||||||
xaccAccountGetLastNum (const Account *acc)
|
xaccAccountGetLastNum (const Account *acc)
|
||||||
{
|
{
|
||||||
GValue v = G_VALUE_INIT;
|
auto priv = GET_PRIVATE (acc);
|
||||||
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
|
if (priv->last_num == is_unset)
|
||||||
qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v, {"last-num"});
|
priv->last_num = get_kvp_string_tag (acc, "last-num");
|
||||||
return G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL;
|
return priv->last_num;
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
@ -4883,16 +4885,11 @@ xaccAccountGetLastNum (const Account *acc)
|
|||||||
void
|
void
|
||||||
xaccAccountSetLastNum (Account *acc, const char *num)
|
xaccAccountSetLastNum (Account *acc, const char *num)
|
||||||
{
|
{
|
||||||
GValue v = G_VALUE_INIT;
|
auto priv = GET_PRIVATE (acc);
|
||||||
g_return_if_fail(GNC_IS_ACCOUNT(acc));
|
if (priv->last_num != is_unset)
|
||||||
g_value_init (&v, G_TYPE_STRING);
|
g_free (priv->last_num);
|
||||||
|
priv->last_num = g_strdup (num);
|
||||||
g_value_set_string (&v, num);
|
set_kvp_string_tag (acc, "last-num", priv->last_num);
|
||||||
xaccAccountBeginEdit (acc);
|
|
||||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, {"last-num"});
|
|
||||||
mark_account (acc);
|
|
||||||
xaccAccountCommitEdit (acc);
|
|
||||||
g_value_unset (&v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Account *
|
static Account *
|
||||||
|
@ -133,6 +133,9 @@ typedef struct AccountPrivate
|
|||||||
TriState equity_type;
|
TriState equity_type;
|
||||||
char *notes;
|
char *notes;
|
||||||
char *color;
|
char *color;
|
||||||
|
char *tax_us_code;
|
||||||
|
char *tax_us_pns;
|
||||||
|
char *last_num;
|
||||||
char *sort_order;
|
char *sort_order;
|
||||||
char *filter;
|
char *filter;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user