[Account.cpp] small modification xaccAccountSetLastNum

if last-num is empty-string, remove the slot. this makes the behaviour
consistent with other slots.
pull/1965/head
Christopher Lam 2 years ago
parent d13f930a8c
commit ecabcef084

@ -4812,13 +4812,18 @@ xaccAccountGetLastNum (const Account *acc)
void
xaccAccountSetLastNum (Account *acc, const char *num)
{
GValue v = G_VALUE_INIT;
g_return_if_fail(GNC_IS_ACCOUNT(acc));
g_value_init (&v, G_TYPE_STRING);
g_value_set_static_string (&v, num);
xaccAccountBeginEdit (acc);
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, {"last-num"});
if (num && *num)
{
GValue v = G_VALUE_INIT;
g_value_init (&v, G_TYPE_STRING);
g_value_set_static_string (&v, num);
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, {"last-num"});
g_value_unset (&v);
}
else
qof_instance_set_path_kvp (QOF_INSTANCE (acc), nullptr, {"last-num"});
mark_account (acc);
xaccAccountCommitEdit (acc);
}

@ -1107,7 +1107,7 @@ test_gnc_account_kvp_setters_getters (Fixture *fixture, gconstpointer pData)
g_assert_cmpstr (xaccAccountGetLastNum (account), ==, "red");
xaccAccountSetLastNum (account, "");
g_assert_cmpstr (xaccAccountGetLastNum (account), ==, "");
g_assert_cmpstr (xaccAccountGetLastNum (account), ==, nullptr);
xaccAccountSetLastNum (account, " ");
g_assert_cmpstr (xaccAccountGetLastNum (account), ==, " ");

Loading…
Cancel
Save