Merge Richard Cohen's 'remove-unused-value-list' into stable.

This commit is contained in:
John Ralls 2023-05-25 10:45:04 -04:00
commit 23c208e1a0
3 changed files with 3 additions and 97 deletions

View File

@ -232,17 +232,6 @@ int compare(const KvpFrameImpl & one, const KvpFrameImpl & two) noexcept
return 0;
}
static void
kvp_value_list_from_gvalue (GValue *gval, gpointer pList)
{
GList **kvplist = (GList**)pList;
KvpValue *kvp;
if (!(gval && G_VALUE_TYPE (gval)))
return;
kvp = kvp_value_from_gvalue (gval);
*kvplist = g_list_prepend (*kvplist, kvp);
}
GValue*
gvalue_from_kvp_value (const KvpValue *kval, GValue* val)
{
@ -283,14 +272,12 @@ gvalue_from_kvp_value (const KvpValue *kval, GValue* val)
g_value_set_static_boxed (val, kval->get_ptr<GDate>());
break;
case KvpValue::Type::GLIST:
{
g_value_init (val, GNC_TYPE_VALUE_LIST);
g_value_set_static_boxed (val, kval->get<GList*>());
break;
}
PWARN ("Error! Attempt to transfer KvpGList!");
[[fallthrough]];
/* No transfer of KVP frames outside of QofInstance-derived classes! */
case KvpValue::Type::FRAME:
PWARN ("Error! Attempt to transfer KvpFrame!");
[[fallthrough]];
default:
PWARN ("Error! Invalid KVP Transfer Request!");
g_slice_free (GValue, val);
@ -338,68 +325,12 @@ kvp_value_from_gvalue (const GValue *gval)
val = new KvpValue(*(Time64*)g_value_get_boxed (gval));
else if (type == G_TYPE_DATE)
val = new KvpValue(*(GDate*)g_value_get_boxed (gval));
else if (type == GNC_TYPE_VALUE_LIST)
{
GList *gvalue_list = (GList*)g_value_get_boxed (gval);
GList *kvp_list = NULL;
g_list_foreach (gvalue_list, (GFunc)kvp_value_list_from_gvalue,
&kvp_list);
kvp_list = g_list_reverse (kvp_list);
val = new KvpValue(kvp_list);
// g_list_free_full (gvalue_list, (GDestroyNotify)g_value_unset);
// gvalue_list = NULL;
}
else
PWARN ("Error! Don't know how to make a KvpValue from a %s",
G_VALUE_TYPE_NAME (gval));
return val;
}
/* The following are required for using KvpValue GLists as GValues */
static void
gnc_gvalue_copy (GValue *src, gpointer uData)
{
GList **new_list = (GList**)uData;
GValue *dest = g_value_init (g_slice_new0 (GValue), G_VALUE_TYPE (src));
g_value_copy (src, dest);
*new_list = g_list_prepend(*new_list, dest);
}
void
gnc_gvalue_free (GValue *val)
{
if (val == NULL || ! G_IS_VALUE (val)) return;
g_value_unset (val);
g_slice_free (GValue, val);
}
static GList*
gnc_value_list_copy (GList *list)
{
GList *new_list = NULL;
g_list_foreach (list, (GFunc)gnc_gvalue_copy, &new_list);
new_list = g_list_reverse (new_list);
return new_list;
}
static void
gnc_value_list_free (GList *list)
{
g_list_free_full (list, (GDestroyNotify)gnc_gvalue_free);
}
GType
gnc_value_list_get_type (void)
{
static GType type = 0;
if (type == 0)
{
type = g_boxed_type_register_static ("gnc_value_list",
(GBoxedCopyFunc)gnc_value_list_copy,
(GBoxedFreeFunc)gnc_value_list_free);
}
return type;
}
void
KvpFrame::flatten_kvp_impl(std::vector <std::string> path, std::vector <KvpEntry> & entries) const noexcept

View File

@ -185,15 +185,7 @@ GValue* gvalue_from_kvp_value (const KvpValue *kval, GValue* val = nullptr);
*/
KvpValue* kvp_value_from_gvalue (const GValue *gval);
/**
* \brief Convenience function to release the value in a GValue
* acquired by kvp_frame_get_gvalue and to free the GValue.
* \param value: A GValue* created by kvp_frame_get_gvalue
*/
void gnc_gvalue_free (GValue *value);
/** @} Close Doxygen Internal */
/** @} Close Doxygen Group */
extern "C" GType gnc_value_list_get_type (void);
#define GNC_TYPE_VALUE_LIST (gnc_value_list_get_type ())
#endif

View File

@ -59,8 +59,6 @@
#include "qofbook.hpp"
static QofLogModule log_module = QOF_MOD_ENGINE;
#define AB_KEY "hbci"
#define AB_TEMPLATES "template-list"
enum
{
@ -72,7 +70,6 @@ enum
PROP_OPT_NUM_FIELD_SOURCE, /* KVP */
PROP_OPT_DEFAULT_BUDGET, /* KVP */
PROP_OPT_FY_END, /* KVP */
PROP_AB_TEMPLATES, /* KVP */
};
static void
@ -180,9 +177,6 @@ qof_book_get_property (GObject* object,
case PROP_OPT_FY_END:
qof_instance_get_path_kvp (QOF_INSTANCE (book), value, {"fy_end"});
break;
case PROP_AB_TEMPLATES:
qof_instance_get_path_kvp (QOF_INSTANCE (book), value, {"AB_KEY", "AB_TEMPLATES"});
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
@ -222,9 +216,6 @@ qof_book_set_property (GObject *object,
case PROP_OPT_FY_END:
qof_instance_set_path_kvp (QOF_INSTANCE (book), value, {"fy_end"});
break;
case PROP_AB_TEMPLATES:
qof_instance_set_path_kvp (QOF_INSTANCE (book), value, {AB_KEY, AB_TEMPLATES});
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
@ -290,14 +281,6 @@ qof_book_class_init (QofBookClass *klass)
"Day of the Fiscal year for the book.",
G_TYPE_DATE,
G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_AB_TEMPLATES,
g_param_spec_boxed("ab-templates",
"AQBanking Template List",
"A GList of AQBanking Templates",
GNC_TYPE_VALUE_LIST,
G_PARAM_READWRITE));
}
QofBook *