mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[gnc-lot.c] GValue string must be unset
This commit is contained in:
parent
ac2afc7e13
commit
0ecbcb4ef1
@ -86,6 +86,9 @@ typedef struct GNCLotPrivate
|
|||||||
/* List of splits that belong to this lot. */
|
/* List of splits that belong to this lot. */
|
||||||
SplitList *splits;
|
SplitList *splits;
|
||||||
|
|
||||||
|
char *title;
|
||||||
|
char *notes;
|
||||||
|
|
||||||
GncInvoice *cached_invoice;
|
GncInvoice *cached_invoice;
|
||||||
/* Handy cached value to indicate if lot is closed. */
|
/* Handy cached value to indicate if lot is closed. */
|
||||||
/* If value is negative, then the cache is invalid. */
|
/* If value is negative, then the cache is invalid. */
|
||||||
@ -103,6 +106,9 @@ typedef struct GNCLotPrivate
|
|||||||
|
|
||||||
/* ============================================================= */
|
/* ============================================================= */
|
||||||
|
|
||||||
|
static char*
|
||||||
|
is_unset = "unset";
|
||||||
|
|
||||||
/* GObject Initialization */
|
/* GObject Initialization */
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE(GNCLot, gnc_lot, QOF_TYPE_INSTANCE)
|
G_DEFINE_TYPE_WITH_PRIVATE(GNCLot, gnc_lot, QOF_TYPE_INSTANCE)
|
||||||
|
|
||||||
@ -116,6 +122,8 @@ gnc_lot_init(GNCLot* lot)
|
|||||||
priv->splits = NULL;
|
priv->splits = NULL;
|
||||||
priv->cached_invoice = NULL;
|
priv->cached_invoice = NULL;
|
||||||
priv->is_closed = LOT_CLOSED_UNKNOWN;
|
priv->is_closed = LOT_CLOSED_UNKNOWN;
|
||||||
|
priv->title = is_unset;
|
||||||
|
priv->notes = is_unset;
|
||||||
priv->marker = 0;
|
priv->marker = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,6 +303,14 @@ gnc_lot_free(GNCLot* lot)
|
|||||||
if (priv->account && !qof_instance_get_destroying(priv->account))
|
if (priv->account && !qof_instance_get_destroying(priv->account))
|
||||||
xaccAccountRemoveLot (priv->account, lot);
|
xaccAccountRemoveLot (priv->account, lot);
|
||||||
|
|
||||||
|
if (priv->notes != is_unset)
|
||||||
|
g_free (priv->notes);
|
||||||
|
|
||||||
|
if (priv->title != is_unset)
|
||||||
|
g_free (priv->title);
|
||||||
|
|
||||||
|
priv->notes = NULL;
|
||||||
|
priv->title = NULL;
|
||||||
priv->account = NULL;
|
priv->account = NULL;
|
||||||
priv->is_closed = TRUE;
|
priv->is_closed = TRUE;
|
||||||
/* qof_instance_release (&lot->inst); */
|
/* qof_instance_release (&lot->inst); */
|
||||||
@ -439,30 +455,46 @@ gint gnc_lot_count_splits (const GNCLot *lot)
|
|||||||
const char *
|
const char *
|
||||||
gnc_lot_get_title (const GNCLot *lot)
|
gnc_lot_get_title (const GNCLot *lot)
|
||||||
{
|
{
|
||||||
GValue v = G_VALUE_INIT;
|
GNCLotPrivate* priv;
|
||||||
if (!lot) return NULL;
|
if (!lot) return NULL;
|
||||||
|
priv = GET_PRIVATE (lot);
|
||||||
|
if (priv->title == is_unset)
|
||||||
|
{
|
||||||
|
GNCLotPrivate* priv = GET_PRIVATE (lot);
|
||||||
|
GValue v = G_VALUE_INIT;
|
||||||
qof_instance_get_kvp (QOF_INSTANCE (lot), &v, 1, "title");
|
qof_instance_get_kvp (QOF_INSTANCE (lot), &v, 1, "title");
|
||||||
if (G_VALUE_HOLDS_STRING (&v))
|
priv->title = G_VALUE_HOLDS_STRING (&v) ? g_value_dup_string (&v) : NULL;
|
||||||
return g_value_get_string (&v);
|
g_value_unset (&v);
|
||||||
return NULL;
|
}
|
||||||
|
return priv->title;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
gnc_lot_get_notes (const GNCLot *lot)
|
gnc_lot_get_notes (const GNCLot *lot)
|
||||||
{
|
{
|
||||||
GValue v = G_VALUE_INIT;
|
GNCLotPrivate* priv;
|
||||||
if (!lot) return NULL;
|
if (!lot) return NULL;
|
||||||
|
priv = GET_PRIVATE (lot);
|
||||||
|
if (priv->notes == is_unset)
|
||||||
|
{
|
||||||
|
GValue v = G_VALUE_INIT;
|
||||||
qof_instance_get_kvp (QOF_INSTANCE (lot), &v, 1, "notes");
|
qof_instance_get_kvp (QOF_INSTANCE (lot), &v, 1, "notes");
|
||||||
if (G_VALUE_HOLDS_STRING (&v))
|
priv->notes = G_VALUE_HOLDS_STRING (&v) ? g_value_dup_string (&v) : NULL;
|
||||||
return g_value_get_string (&v);
|
g_value_unset (&v);
|
||||||
return NULL;
|
}
|
||||||
|
return priv->notes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gnc_lot_set_title (GNCLot *lot, const char *str)
|
gnc_lot_set_title (GNCLot *lot, const char *str)
|
||||||
{
|
{
|
||||||
GValue v = G_VALUE_INIT;
|
GValue v = G_VALUE_INIT;
|
||||||
|
GNCLotPrivate* priv;
|
||||||
if (!lot) return;
|
if (!lot) return;
|
||||||
|
priv = GET_PRIVATE (lot);
|
||||||
|
if (priv->title != is_unset)
|
||||||
|
g_free (priv->title);
|
||||||
|
|
||||||
qof_begin_edit(QOF_INSTANCE(lot));
|
qof_begin_edit(QOF_INSTANCE(lot));
|
||||||
g_value_init (&v, G_TYPE_STRING);
|
g_value_init (&v, G_TYPE_STRING);
|
||||||
g_value_set_string (&v, str);
|
g_value_set_string (&v, str);
|
||||||
@ -476,7 +508,11 @@ void
|
|||||||
gnc_lot_set_notes (GNCLot *lot, const char *str)
|
gnc_lot_set_notes (GNCLot *lot, const char *str)
|
||||||
{
|
{
|
||||||
GValue v = G_VALUE_INIT;
|
GValue v = G_VALUE_INIT;
|
||||||
|
GNCLotPrivate* priv;
|
||||||
if (!lot) return;
|
if (!lot) return;
|
||||||
|
priv = GET_PRIVATE (lot);
|
||||||
|
if (priv->notes != is_unset)
|
||||||
|
g_free (priv->notes);
|
||||||
qof_begin_edit(QOF_INSTANCE(lot));
|
qof_begin_edit(QOF_INSTANCE(lot));
|
||||||
g_value_init (&v, G_TYPE_STRING);
|
g_value_init (&v, G_TYPE_STRING);
|
||||||
g_value_set_string (&v, str);
|
g_value_set_string (&v, str);
|
||||||
|
Loading…
Reference in New Issue
Block a user