diff --git a/libgnucash/engine/Split.c b/libgnucash/engine/Split.c index af95889825..b36e59bbfc 100644 --- a/libgnucash/engine/Split.c +++ b/libgnucash/engine/Split.c @@ -97,7 +97,6 @@ enum }; -static const char * is_unset = "unset"; static const char * split_type_normal = "normal"; static const char * split_type_stock_split = "stock-split"; @@ -120,7 +119,6 @@ gnc_split_init(Split* split) split->value = gnc_numeric_zero(); split->date_reconciled = 0; - split->split_type = is_unset; split->balance = gnc_numeric_zero(); split->cleared_balance = gnc_numeric_zero(); @@ -721,7 +719,6 @@ xaccFreeSplit (Split *split) split->lot = NULL; split->acc = NULL; split->orig_acc = NULL; - split->split_type = NULL; split->date_reconciled = 0; G_OBJECT_CLASS (QOF_INSTANCE_GET_CLASS (&split->inst))->dispose(G_OBJECT (split)); @@ -1969,25 +1966,24 @@ const char * xaccSplitGetType(const Split *s) { if (!s) return NULL; - if (s->split_type == is_unset) + + GValue v = G_VALUE_INIT; + Split *split = (Split*) s; + const char* type; + qof_instance_get_kvp (QOF_INSTANCE (s), &v, 1, "split-type"); + type = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL; + const char *rv; + if (!type || !g_strcmp0 (type, split_type_normal)) + rv = split_type_normal; + else if (!g_strcmp0 (type, split_type_stock_split)) + rv = split_type_stock_split; + else { - GValue v = G_VALUE_INIT; - Split *split = (Split*) s; - const char* type; - qof_instance_get_kvp (QOF_INSTANCE (s), &v, 1, "split-type"); - type = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL; - if (!type || !g_strcmp0 (type, split_type_normal)) - split->split_type = (char*) split_type_normal; - else if (!g_strcmp0 (type, split_type_stock_split)) - split->split_type = (char*) split_type_stock_split; - else - { - PERR ("unexpected split-type %s, reset to normal.", type); - split->split_type = split_type_normal; - } - g_value_unset (&v); + PERR ("unexpected split-type %s, reset to normal.", type); + rv = split_type_normal; } - return s->split_type; + g_value_unset (&v); + return rv; } /* reconfigure a split to be a stock split - after this, you shouldn't @@ -2001,7 +1997,6 @@ xaccSplitMakeStockSplit(Split *s) s->value = gnc_numeric_zero(); g_value_init (&v, G_TYPE_STRING); g_value_set_static_string (&v, split_type_stock_split); - s->split_type = split_type_stock_split; qof_instance_set_kvp (QOF_INSTANCE (s), &v, 1, "split-type"); SET_GAINS_VDIRTY(s); mark_split(s);