mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Merge branch 'maint-leaks' into maint #1019
This commit is contained in:
commit
321b5efabc
@ -572,6 +572,7 @@ gnc_add_history (QofSession * session)
|
||||
file = gnc_uri_normalize_uri ( url, FALSE ); /* Note that the password is not saved in history ! */
|
||||
|
||||
gnc_history_add_file (file);
|
||||
g_free (file);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -544,6 +544,10 @@ gnc_plugin_page_finalize (GObject *object)
|
||||
page = GNC_PLUGIN_PAGE(object);
|
||||
|
||||
priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
|
||||
|
||||
if (priv->ui_description)
|
||||
g_free (priv->ui_description);
|
||||
|
||||
if (priv->page_name)
|
||||
g_free (priv->page_name);
|
||||
|
||||
|
@ -235,11 +235,8 @@ gnc_plugin_init_short_names (GtkActionGroup *action_group,
|
||||
action_toolbar_labels *toolbar_labels)
|
||||
{
|
||||
GtkAction *action;
|
||||
GValue value = { 0, };
|
||||
gint i;
|
||||
|
||||
g_value_init (&value, G_TYPE_STRING);
|
||||
|
||||
for (i = 0; toolbar_labels[i].action_name; i++)
|
||||
{
|
||||
/* Add a couple of short labels for the toolbar */
|
||||
@ -306,6 +303,7 @@ gnc_plugin_update_actions (GtkActionGroup *action_group,
|
||||
g_list_length(gtk_action_group_list_actions(action_group)));
|
||||
}
|
||||
}
|
||||
g_value_unset (&gvalue);
|
||||
}
|
||||
|
||||
|
||||
|
@ -580,6 +580,7 @@ gnc_simple_combo_get_value (GtkComboBox *cbox)
|
||||
GtkTreeIter iter;
|
||||
GtkTreeModel *model;
|
||||
GValue value = { 0 };
|
||||
gpointer retval;
|
||||
|
||||
if (!cbox) return NULL;
|
||||
|
||||
@ -587,7 +588,9 @@ gnc_simple_combo_get_value (GtkComboBox *cbox)
|
||||
if (!gtk_combo_box_get_active_iter (cbox, &iter))
|
||||
return NULL;
|
||||
gtk_tree_model_get_value (model, &iter, 1, &value);
|
||||
return g_value_get_pointer (&value);
|
||||
retval = g_value_get_pointer (&value);
|
||||
g_value_unset (&value);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/** Find the item in the combo box whose value is "data"
|
||||
@ -615,6 +618,7 @@ gnc_simple_combo_set_value (GtkComboBox *cbox, gpointer data)
|
||||
if ((lsd->is_equal)(g_value_get_pointer(&value), data))
|
||||
{
|
||||
gtk_combo_box_set_active_iter (cbox, &iter);
|
||||
g_value_unset (&value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -623,9 +627,11 @@ gnc_simple_combo_set_value (GtkComboBox *cbox, gpointer data)
|
||||
if (g_value_get_pointer(&value) == data)
|
||||
{
|
||||
gtk_combo_box_set_active_iter (cbox, &iter);
|
||||
g_value_unset (&value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
g_value_unset (&value);
|
||||
valid_iter = gtk_tree_model_iter_next (model, &iter);
|
||||
}
|
||||
}
|
||||
|
@ -639,6 +639,7 @@ gnc_budget_view_restore (GncBudgetView *budget_view, GKeyFile *key_file, const g
|
||||
GncGUID guid;
|
||||
GncBudget *bgt;
|
||||
QofBook *book;
|
||||
gboolean has_guid;
|
||||
|
||||
g_return_val_if_fail (key_file, FALSE);
|
||||
g_return_val_if_fail (group_name, FALSE);
|
||||
@ -655,7 +656,10 @@ gnc_budget_view_restore (GncBudgetView *budget_view, GKeyFile *key_file, const g
|
||||
error = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
if (!string_to_guid (guid_str, &guid))
|
||||
has_guid = string_to_guid (guid_str, &guid);
|
||||
g_free (guid_str);
|
||||
|
||||
if (!has_guid)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -373,6 +373,7 @@ gnc_plugin_page_owner_tree_new (GncOwnerType owner_type)
|
||||
g_object_set_property (G_OBJECT(action), "visible", &gvalue);
|
||||
}
|
||||
|
||||
g_value_unset (&gvalue);
|
||||
LEAVE("new %s tree page %p", gncOwnerTypeToQofIdType(owner_type), plugin_page);
|
||||
return GNC_PLUGIN_PAGE(plugin_page);
|
||||
}
|
||||
|
@ -2481,6 +2481,7 @@ set_kvp_string_tag (Account *acc, const char *tag, const char *value)
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
g_value_set_string (&v, tmp);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, {tag});
|
||||
g_value_unset (&v);
|
||||
}
|
||||
else
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), NULL, {tag});
|
||||
@ -4036,21 +4037,24 @@ set_boolean_key (Account *acc, std::vector<std::string> const & path, gboolean o
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, path);
|
||||
mark_account (acc);
|
||||
xaccAccountCommitEdit (acc);
|
||||
g_value_unset (&v);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
boolean_from_key (const Account *acc, std::vector<std::string> const & path)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
gboolean retval = FALSE;
|
||||
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v, path);
|
||||
if (G_VALUE_HOLDS_INT64 (&v))
|
||||
return g_value_get_int64 (&v) != 0;
|
||||
retval = (g_value_get_int64 (&v) != 0);
|
||||
if (G_VALUE_HOLDS_BOOLEAN (&v))
|
||||
return g_value_get_boolean (&v);
|
||||
retval = (g_value_get_boolean (&v));
|
||||
if (G_VALUE_HOLDS_STRING (&v))
|
||||
return strcmp (g_value_get_string (&v), "true") == 0;
|
||||
return FALSE;
|
||||
retval = !strcmp (g_value_get_string (&v), "true");
|
||||
g_value_unset (&v);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@ -4090,6 +4094,7 @@ xaccAccountSetTaxUSCode (Account *acc, const char *code)
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, {"tax-US", "code"});
|
||||
mark_account (acc);
|
||||
xaccAccountCommitEdit (acc);
|
||||
g_value_unset (&v);
|
||||
}
|
||||
|
||||
const char *
|
||||
@ -4113,6 +4118,7 @@ xaccAccountSetTaxUSPayerNameSource (Account *acc, const char *source)
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, {"tax-US", "payer-name-source"});
|
||||
mark_account (acc);
|
||||
xaccAccountCommitEdit (acc);
|
||||
g_value_unset (&v);
|
||||
}
|
||||
|
||||
gint64
|
||||
@ -4125,6 +4131,7 @@ xaccAccountGetTaxUSCopyNumber (const Account *acc)
|
||||
if (G_VALUE_HOLDS_INT64 (&v))
|
||||
copy_number = g_value_get_int64 (&v);
|
||||
|
||||
g_value_unset (&v);
|
||||
return (copy_number == 0) ? 1 : copy_number;
|
||||
}
|
||||
|
||||
@ -4139,6 +4146,7 @@ xaccAccountSetTaxUSCopyNumber (Account *acc, gint64 copy_number)
|
||||
g_value_init (&v, G_TYPE_INT64);
|
||||
g_value_set_int64 (&v, copy_number);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, {"tax-US", "copy-number"});
|
||||
g_value_unset (&v);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -4627,18 +4635,21 @@ xaccAccountGetReconcileLastDate (const Account *acc, time64 *last_date)
|
||||
{
|
||||
gint64 date = 0;
|
||||
GValue v = G_VALUE_INIT;
|
||||
gboolean retval = FALSE;
|
||||
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v, {KEY_RECONCILE_INFO, "last-date"});
|
||||
if (G_VALUE_HOLDS_INT64 (&v))
|
||||
date = g_value_get_int64 (&v);
|
||||
|
||||
g_value_unset (&v);
|
||||
if (date)
|
||||
{
|
||||
if (last_date)
|
||||
*last_date = date;
|
||||
return TRUE;
|
||||
retval = TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
g_value_unset (&v);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@ -4656,6 +4667,7 @@ xaccAccountSetReconcileLastDate (Account *acc, time64 last_date)
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, {KEY_RECONCILE_INFO, "last-date"});
|
||||
mark_account (acc);
|
||||
xaccAccountCommitEdit (acc);
|
||||
g_value_unset (&v);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@ -4667,6 +4679,7 @@ xaccAccountGetReconcileLastInterval (const Account *acc,
|
||||
{
|
||||
GValue v1 = G_VALUE_INIT, v2 = G_VALUE_INIT;
|
||||
int64_t m = 0, d = 0;
|
||||
gboolean retval = FALSE;
|
||||
|
||||
if (!acc) return FALSE;
|
||||
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
|
||||
@ -4684,9 +4697,11 @@ xaccAccountGetReconcileLastInterval (const Account *acc,
|
||||
*months = m;
|
||||
if (days)
|
||||
*days = d;
|
||||
return TRUE;
|
||||
retval = TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
g_value_unset (&v1);
|
||||
g_value_unset (&v2);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@ -4709,6 +4724,8 @@ xaccAccountSetReconcileLastInterval (Account *acc, int months, int days)
|
||||
{KEY_RECONCILE_INFO, "last-interval", "days"});
|
||||
mark_account (acc);
|
||||
xaccAccountCommitEdit (acc);
|
||||
g_value_unset (&v1);
|
||||
g_value_unset (&v2);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@ -4718,6 +4735,7 @@ gboolean
|
||||
xaccAccountGetReconcilePostponeDate (const Account *acc, time64 *postpone_date)
|
||||
{
|
||||
gint64 date = 0;
|
||||
gboolean retval = FALSE;
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v,
|
||||
@ -4729,9 +4747,10 @@ xaccAccountGetReconcilePostponeDate (const Account *acc, time64 *postpone_date)
|
||||
{
|
||||
if (postpone_date)
|
||||
*postpone_date = date;
|
||||
return TRUE;
|
||||
retval = TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
g_value_unset (&v);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@ -4750,6 +4769,7 @@ xaccAccountSetReconcilePostponeDate (Account *acc, time64 postpone_date)
|
||||
{KEY_RECONCILE_INFO, KEY_POSTPONE, "date"});
|
||||
mark_account (acc);
|
||||
xaccAccountCommitEdit (acc);
|
||||
g_value_unset (&v);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@ -4761,20 +4781,22 @@ xaccAccountGetReconcilePostponeBalance (const Account *acc,
|
||||
{
|
||||
gnc_numeric bal = gnc_numeric_zero ();
|
||||
GValue v = G_VALUE_INIT;
|
||||
gboolean retval = FALSE;
|
||||
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v,
|
||||
{KEY_RECONCILE_INFO, KEY_POSTPONE, "balance"});
|
||||
if (!G_VALUE_HOLDS_INT64 (&v))
|
||||
return FALSE;
|
||||
|
||||
bal = *(gnc_numeric*)g_value_get_boxed (&v);
|
||||
if (!bal.denom)
|
||||
return FALSE;
|
||||
|
||||
if (balance)
|
||||
*balance = bal;
|
||||
|
||||
return TRUE;
|
||||
if (G_VALUE_HOLDS_INT64 (&v))
|
||||
{
|
||||
bal = *(gnc_numeric*)g_value_get_boxed (&v);
|
||||
if (bal.denom)
|
||||
{
|
||||
if (balance)
|
||||
*balance = bal;
|
||||
retval = TRUE;
|
||||
}
|
||||
}
|
||||
g_value_unset (&v);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@ -4793,6 +4815,7 @@ xaccAccountSetReconcilePostponeBalance (Account *acc, gnc_numeric balance)
|
||||
{KEY_RECONCILE_INFO, KEY_POSTPONE, "balance"});
|
||||
mark_account (acc);
|
||||
xaccAccountCommitEdit (acc);
|
||||
g_value_unset (&v);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@ -4837,6 +4860,7 @@ xaccAccountSetLastNum (Account *acc, const char *num)
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, {"last-num"});
|
||||
mark_account (acc);
|
||||
xaccAccountCommitEdit (acc);
|
||||
g_value_unset (&v);
|
||||
}
|
||||
|
||||
static Account *
|
||||
@ -4909,6 +4933,7 @@ xaccAccountGainsAccount (Account *acc, gnc_commodity *curr)
|
||||
g_value_set_boxed (&vr, guid);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &vr, path);
|
||||
qof_instance_set_dirty (QOF_INSTANCE (acc));
|
||||
g_value_unset (&vr);
|
||||
}
|
||||
xaccAccountCommitEdit (acc);
|
||||
}
|
||||
@ -4916,6 +4941,7 @@ xaccAccountGainsAccount (Account *acc, gnc_commodity *curr)
|
||||
gains_account = xaccAccountLookup (guid,
|
||||
qof_instance_get_book(acc));
|
||||
|
||||
g_value_unset (&v);
|
||||
return gains_account;
|
||||
}
|
||||
|
||||
@ -4936,6 +4962,7 @@ dxaccAccountSetPriceSrc(Account *acc, const char *src)
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
g_value_set_string (&v, src);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE(acc), &v, {"old-price-source"});
|
||||
g_value_unset (&v);
|
||||
}
|
||||
else
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE(acc), nullptr, {"old-price-source"});
|
||||
@ -5010,6 +5037,7 @@ xaccAccountSetReconcileChildrenStatus(Account *acc, gboolean status)
|
||||
{KEY_RECONCILE_INFO, KEY_INCLUDE_CHILDREN});
|
||||
mark_account(acc);
|
||||
xaccAccountCommitEdit (acc);
|
||||
g_value_unset (&v);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@ -5023,10 +5051,13 @@ xaccAccountGetReconcileChildrenStatus(const Account *acc)
|
||||
* the default behaviour
|
||||
*/
|
||||
GValue v = G_VALUE_INIT;
|
||||
gboolean retval;
|
||||
if (!acc) return FALSE;
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE (acc), &v,
|
||||
{KEY_RECONCILE_INFO, KEY_INCLUDE_CHILDREN});
|
||||
return G_VALUE_HOLDS_INT64 (&v) ? g_value_get_int64 (&v) : FALSE;
|
||||
retval = G_VALUE_HOLDS_INT64 (&v) ? g_value_get_int64 (&v) : FALSE;
|
||||
g_value_unset (&v);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@ -5399,6 +5430,7 @@ gnc_account_imap_find_account (GncImportMatchMap *imap,
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
GncGUID * guid = NULL;
|
||||
Account *retval;
|
||||
if (!imap || !key) return NULL;
|
||||
std::vector<std::string> path {IMAP_FRAME};
|
||||
if (category)
|
||||
@ -5407,7 +5439,9 @@ gnc_account_imap_find_account (GncImportMatchMap *imap,
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE (imap->acc), &v, path);
|
||||
if (G_VALUE_HOLDS_BOXED (&v))
|
||||
guid = (GncGUID*)g_value_get_boxed (&v);
|
||||
return xaccAccountLookup (guid, imap->book);
|
||||
retval = xaccAccountLookup (guid, imap->book);
|
||||
g_value_unset (&v);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Store an Account in the map */
|
||||
@ -5429,6 +5463,7 @@ gnc_account_imap_add_account (GncImportMatchMap *imap,
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (imap->acc), &v, path);
|
||||
qof_instance_set_dirty (QOF_INSTANCE (imap->acc));
|
||||
xaccAccountCommitEdit (imap->acc);
|
||||
g_value_unset (&v);
|
||||
}
|
||||
|
||||
/* Remove a reference to an Account in the map */
|
||||
@ -5798,6 +5833,7 @@ change_imap_entry (GncImportMatchMap *imap, std::string const & path, int64_t to
|
||||
// Add or Update the entry based on guid
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (imap->acc), &value, {path});
|
||||
gnc_features_set_used (imap->book, GNC_FEATURE_GUID_FLAT_BAYESIAN);
|
||||
g_value_unset (&value);
|
||||
}
|
||||
|
||||
/** Updates the imap for a given account using a list of tokens */
|
||||
@ -5968,6 +6004,7 @@ gnc_account_get_map_entry (Account *acc, const char *head, const char *category)
|
||||
text = g_strdup (string);
|
||||
}
|
||||
}
|
||||
g_value_unset (&v);
|
||||
return text;
|
||||
}
|
||||
|
||||
|
@ -1341,6 +1341,7 @@ xaccAccountScrubKvp (Account *account)
|
||||
(G_VALUE_HOLDS_BOOLEAN (&v) && ! g_value_get_boolean (&v)))
|
||||
qof_instance_slot_delete (QOF_INSTANCE (account), "placeholder");
|
||||
|
||||
g_value_unset (&v);
|
||||
qof_instance_slot_delete_if_empty (QOF_INSTANCE (account), "hbci");
|
||||
scrub_depth--;
|
||||
}
|
||||
@ -1351,11 +1352,16 @@ void
|
||||
xaccAccountScrubColorNotSet (QofBook *book)
|
||||
{
|
||||
GValue value_s = G_VALUE_INIT;
|
||||
gboolean already_scrubbed;
|
||||
|
||||
// get the run-once value
|
||||
qof_instance_get_kvp (QOF_INSTANCE (book), &value_s, 1, "remove-color-not-set-slots");
|
||||
|
||||
if (G_VALUE_HOLDS_STRING (&value_s) && (strcmp(g_value_get_string (&value_s), "true") == 0))
|
||||
already_scrubbed = (G_VALUE_HOLDS_STRING (&value_s) &&
|
||||
!g_strcmp0 (g_value_get_string (&value_s), "true"));
|
||||
g_value_unset (&value_s);
|
||||
|
||||
if (already_scrubbed)
|
||||
return;
|
||||
else
|
||||
{
|
||||
@ -1378,6 +1384,7 @@ xaccAccountScrubColorNotSet (QofBook *book)
|
||||
|
||||
// set the run-once value
|
||||
qof_instance_set_kvp (QOF_INSTANCE (book), &value_b, 1, "remove-color-not-set-slots");
|
||||
g_value_unset (&value_b);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1115,6 +1115,7 @@ xaccSplitDetermineGainStatus (Split *split)
|
||||
other = (Split *) qof_collection_lookup_entity (col, guid);
|
||||
split->gains_split = other;
|
||||
}
|
||||
g_value_unset (&v);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@ -1993,6 +1994,7 @@ xaccSplitMakeStockSplit(Split *s)
|
||||
mark_split(s);
|
||||
qof_instance_set_dirty(QOF_INSTANCE(s));
|
||||
xaccTransCommitEdit(s->parent);
|
||||
g_value_unset (&v);
|
||||
}
|
||||
|
||||
void
|
||||
@ -2124,11 +2126,14 @@ xaccSplitVoidFormerAmount(const Split *split)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
gnc_numeric *num = NULL;
|
||||
gnc_numeric retval;
|
||||
g_return_val_if_fail(split, gnc_numeric_zero());
|
||||
qof_instance_get_kvp (QOF_INSTANCE (split), &v, 1, void_former_amt_str);
|
||||
if (G_VALUE_HOLDS_BOXED (&v))
|
||||
num = (gnc_numeric*)g_value_get_boxed (&v);
|
||||
return num ? *num : gnc_numeric_zero();
|
||||
retval = num ? *num : gnc_numeric_zero();
|
||||
g_value_unset (&v);
|
||||
return retval;
|
||||
}
|
||||
|
||||
gnc_numeric
|
||||
@ -2136,11 +2141,14 @@ xaccSplitVoidFormerValue(const Split *split)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
gnc_numeric *num = NULL;
|
||||
gnc_numeric retval;
|
||||
g_return_val_if_fail(split, gnc_numeric_zero());
|
||||
qof_instance_get_kvp (QOF_INSTANCE (split), &v, 1, void_former_val_str);
|
||||
if (G_VALUE_HOLDS_BOXED (&v))
|
||||
num = (gnc_numeric*)g_value_get_boxed (&v);
|
||||
return num ? *num : gnc_numeric_zero();
|
||||
retval = num ? *num : gnc_numeric_zero();
|
||||
g_value_unset (&v);
|
||||
return retval;
|
||||
}
|
||||
|
||||
void
|
||||
@ -2153,6 +2161,7 @@ xaccSplitVoid(Split *split)
|
||||
num = xaccSplitGetAmount(split);
|
||||
g_value_set_boxed (&v, &num);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (split), &v, 1, void_former_amt_str);
|
||||
g_value_reset (&v);
|
||||
num = xaccSplitGetValue(split);
|
||||
g_value_set_boxed (&v, &num);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (split), &v, 1, void_former_val_str);
|
||||
@ -2161,6 +2170,7 @@ xaccSplitVoid(Split *split)
|
||||
xaccSplitSetAmount (split, zero);
|
||||
xaccSplitSetValue (split, zero);
|
||||
xaccSplitSetReconcile(split, VREC);
|
||||
g_value_unset (&v);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2001,6 +2001,7 @@ xaccTransSetDatePostedGDate (Transaction *trans, GDate date)
|
||||
g_value_init (&v, G_TYPE_DATE);
|
||||
g_value_set_boxed (&v, &date);
|
||||
qof_instance_set_kvp (QOF_INSTANCE(trans), &v, 1, TRANS_DATE_POSTED);
|
||||
g_value_unset (&v);
|
||||
/* mark dirty and commit handled by SetDateInternal */
|
||||
xaccTransSetDateInternal(trans, &trans->date_posted,
|
||||
gdate_to_time64(date));
|
||||
@ -2060,6 +2061,7 @@ xaccTransSetDateDue (Transaction * trans, time64 time)
|
||||
xaccTransBeginEdit(trans);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), &v, 1, TRANS_DATE_DUE_KVP);
|
||||
qof_instance_set_dirty(QOF_INSTANCE(trans));
|
||||
g_value_unset (&v);
|
||||
xaccTransCommitEdit(trans);
|
||||
}
|
||||
|
||||
@ -2074,6 +2076,7 @@ xaccTransSetTxnType (Transaction *trans, char type)
|
||||
xaccTransBeginEdit(trans);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), &v, 1, TRANS_TXN_TYPE_KVP);
|
||||
qof_instance_set_dirty(QOF_INSTANCE(trans));
|
||||
g_value_unset (&v);
|
||||
xaccTransCommitEdit(trans);
|
||||
}
|
||||
|
||||
@ -2103,6 +2106,7 @@ xaccTransSetReadOnly (Transaction *trans, const char *reason)
|
||||
xaccTransBeginEdit(trans);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), &v, 1, TRANS_READ_ONLY_REASON);
|
||||
qof_instance_set_dirty(QOF_INSTANCE(trans));
|
||||
g_value_unset (&v);
|
||||
xaccTransCommitEdit(trans);
|
||||
|
||||
g_free (trans->readonly_reason);
|
||||
@ -2168,6 +2172,7 @@ xaccTransSetDocLink (Transaction *trans, const char *doclink)
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
g_value_set_string (&v, doclink);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), &v, 1, doclink_uri_str);
|
||||
g_value_unset (&v);
|
||||
}
|
||||
qof_instance_set_dirty(QOF_INSTANCE(trans));
|
||||
xaccTransCommitEdit(trans);
|
||||
@ -2192,6 +2197,7 @@ xaccTransSetNotes (Transaction *trans, const char *notes)
|
||||
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), &v, 1, trans_notes_str);
|
||||
qof_instance_set_dirty(QOF_INSTANCE(trans));
|
||||
g_value_unset (&v);
|
||||
xaccTransCommitEdit(trans);
|
||||
}
|
||||
|
||||
@ -2207,6 +2213,7 @@ xaccTransSetIsClosingTxn (Transaction *trans, gboolean is_closing)
|
||||
g_value_init (&v, G_TYPE_INT64);
|
||||
g_value_set_int64 (&v, 1);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), &v, 1, trans_is_closing_str);
|
||||
g_value_unset (&v);
|
||||
trans->isClosingTxn_cached = 1;
|
||||
}
|
||||
else
|
||||
@ -2381,6 +2388,7 @@ xaccTransGetIsClosingTxn (const Transaction *trans)
|
||||
trans_nonconst->isClosingTxn_cached = (g_value_get_int64 (&v) ? 1 : 0);
|
||||
else
|
||||
trans_nonconst->isClosingTxn_cached = 0;
|
||||
g_value_unset (&v);
|
||||
}
|
||||
return (trans->isClosingTxn_cached == 1)
|
||||
? TRUE
|
||||
@ -2424,6 +2432,7 @@ xaccTransGetDatePostedGDate (const Transaction *trans)
|
||||
qof_instance_get_kvp (QOF_INSTANCE (trans), &v, 1, TRANS_DATE_POSTED);
|
||||
if (G_VALUE_HOLDS_BOXED (&v))
|
||||
result = *(GDate*)g_value_get_boxed (&v);
|
||||
g_value_unset (&v);
|
||||
if (! g_date_valid (&result) || gdate_to_time64 (result) == INT64_MAX)
|
||||
{
|
||||
/* Well, this txn doesn't have a valid GDate saved in a slot.
|
||||
@ -2472,15 +2481,18 @@ xaccTransGetTxnType (const Transaction *trans)
|
||||
{
|
||||
const char *s = NULL;
|
||||
GValue v = G_VALUE_INIT;
|
||||
char ret = TXN_TYPE_NONE;
|
||||
|
||||
if (!trans) return TXN_TYPE_NONE;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (trans), &v, 1, TRANS_TXN_TYPE_KVP);
|
||||
if (G_VALUE_HOLDS_STRING (&v))
|
||||
{
|
||||
s = g_value_get_string (&v);
|
||||
if (s && strlen (s) == 1)
|
||||
return *s;
|
||||
|
||||
return TXN_TYPE_NONE;
|
||||
if (s && strlen (s) == 1)
|
||||
ret = s[0];
|
||||
}
|
||||
g_value_unset (&v);
|
||||
return ret;
|
||||
}
|
||||
|
||||
const char *
|
||||
@ -2712,6 +2724,7 @@ xaccTransVoid(Transaction *trans, const char *reason)
|
||||
gnc_time64_to_iso8601_buff (gnc_time(NULL), iso8601_str);
|
||||
g_value_set_string (&v, iso8601_str);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), &v, 1, void_time_str);
|
||||
g_value_unset (&v);
|
||||
|
||||
FOR_EACH_SPLIT(trans, xaccSplitVoid(s));
|
||||
|
||||
@ -2725,12 +2738,17 @@ xaccTransGetVoidStatus(const Transaction *trans)
|
||||
{
|
||||
const char *s = NULL;
|
||||
GValue v = G_VALUE_INIT;
|
||||
gboolean retval = FALSE;
|
||||
g_return_val_if_fail(trans, FALSE);
|
||||
|
||||
qof_instance_get_kvp (QOF_INSTANCE (trans), &v, 1, void_reason_str);
|
||||
if (G_VALUE_HOLDS_STRING (&v))
|
||||
{
|
||||
s = g_value_get_string (&v);
|
||||
return s && strlen(s);
|
||||
retval = (s && (s[0] != '\0'));
|
||||
}
|
||||
g_value_unset (&v);
|
||||
return retval;
|
||||
}
|
||||
|
||||
const char *
|
||||
@ -2755,9 +2773,12 @@ xaccTransGetVoidTime(const Transaction *tr)
|
||||
g_return_val_if_fail(tr, void_time);
|
||||
qof_instance_get_kvp (QOF_INSTANCE (tr), &v, 1, void_time_str);
|
||||
if (G_VALUE_HOLDS_STRING (&v))
|
||||
{
|
||||
s = g_value_get_string (&v);
|
||||
if (s)
|
||||
return gnc_iso8601_to_time64_gmt (s);
|
||||
if (s)
|
||||
void_time = gnc_iso8601_to_time64_gmt (s);
|
||||
}
|
||||
g_value_unset (&v);
|
||||
return void_time;
|
||||
}
|
||||
|
||||
@ -2771,6 +2792,7 @@ xaccTransUnvoid (Transaction *trans)
|
||||
qof_instance_get_kvp (QOF_INSTANCE (trans), &v, 1, void_reason_str);
|
||||
if (G_VALUE_HOLDS_STRING (&v))
|
||||
s = g_value_get_string (&v);
|
||||
g_value_unset (&v);
|
||||
if (s == NULL) return; /* Transaction isn't voided. Bail. */
|
||||
xaccTransBeginEdit(trans);
|
||||
|
||||
@ -2780,6 +2802,7 @@ xaccTransUnvoid (Transaction *trans)
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), NULL, 1, void_former_notes_str);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), NULL, 1, void_reason_str);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), NULL, 1, void_time_str);
|
||||
g_value_unset (&v);
|
||||
|
||||
FOR_EACH_SPLIT(trans, xaccSplitUnvoid(s));
|
||||
|
||||
@ -2810,6 +2833,7 @@ xaccTransReverse (Transaction *orig)
|
||||
g_value_init (&v, GNC_TYPE_GUID);
|
||||
g_value_set_boxed (&v, xaccTransGetGUID(trans));
|
||||
qof_instance_set_kvp (QOF_INSTANCE (orig), &v, 1, TRANS_REVERSED_BY);
|
||||
g_value_unset (&v);
|
||||
|
||||
/* Make sure the reverse transaction is not read-only */
|
||||
xaccTransClearReadOnly(trans);
|
||||
@ -2823,12 +2847,16 @@ Transaction *
|
||||
xaccTransGetReversedBy(const Transaction *trans)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
Transaction *retval = NULL;
|
||||
g_return_val_if_fail(trans, NULL);
|
||||
qof_instance_get_kvp (QOF_INSTANCE(trans), &v, 1, TRANS_REVERSED_BY);
|
||||
if (G_VALUE_HOLDS_BOXED (&v))
|
||||
return xaccTransLookup((GncGUID*)g_value_get_boxed (&v),
|
||||
qof_instance_get_book(trans));
|
||||
return NULL;
|
||||
{
|
||||
GncGUID* guid = g_value_get_boxed (&v);
|
||||
retval = xaccTransLookup(guid, qof_instance_get_book (trans));
|
||||
}
|
||||
g_value_unset (&v);
|
||||
return retval;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -534,6 +534,7 @@ gnc_budget_set_account_period_value(GncBudget *budget, const Account *account,
|
||||
g_value_init (&v, GNC_TYPE_NUMERIC);
|
||||
g_value_set_boxed (&v, &val);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (budget), &v, 2, path_part_one, path_part_two);
|
||||
g_value_unset (&v);
|
||||
}
|
||||
qof_instance_set_dirty(&budget->inst);
|
||||
gnc_budget_commit_edit(budget);
|
||||
@ -621,6 +622,7 @@ gnc_budget_set_account_period_note(GncBudget *budget, const Account *account,
|
||||
g_value_set_string (&v, note);
|
||||
|
||||
qof_instance_set_kvp (QOF_INSTANCE (budget), &v, 3, GNC_BUDGET_NOTES_PATH, path_part_one, path_part_two);
|
||||
g_value_unset (&v);
|
||||
}
|
||||
qof_instance_set_dirty(&budget->inst);
|
||||
gnc_budget_commit_edit(budget);
|
||||
|
@ -1118,13 +1118,15 @@ static gboolean
|
||||
gnc_commodity_get_auto_quote_control_flag(const gnc_commodity *cm)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
gboolean retval = TRUE;
|
||||
|
||||
if (!cm) return FALSE;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (cm), &v, 1, "auto_quote_control");
|
||||
if (G_VALUE_HOLDS_STRING (&v) &&
|
||||
strcmp(g_value_get_string (&v), "false") == 0)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
retval = FALSE;
|
||||
g_value_unset (&v);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
@ -1360,6 +1362,7 @@ gnc_commodity_set_auto_quote_control_flag(gnc_commodity *cm,
|
||||
g_value_set_string (&v, "false");
|
||||
qof_instance_set_kvp (QOF_INSTANCE (cm), &v, 1, "auto_quote_control");
|
||||
}
|
||||
g_value_unset (&v);
|
||||
mark_commodity_dirty(cm);
|
||||
gnc_commodity_commit_edit(cm);
|
||||
LEAVE("");
|
||||
@ -1494,6 +1497,7 @@ gnc_commodity_set_user_symbol(gnc_commodity * cm, const char * user_symbol)
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
g_value_set_string (&v, user_symbol);
|
||||
qof_instance_set_kvp (QOF_INSTANCE(cm), &v, 1, "user_symbol");
|
||||
g_value_unset (&v);
|
||||
}
|
||||
else
|
||||
qof_instance_set_kvp (QOF_INSTANCE(cm), NULL, 1, "user_symbol");
|
||||
|
@ -469,6 +469,7 @@ gnc_lot_set_title (GNCLot *lot, const char *str)
|
||||
qof_instance_set_kvp (QOF_INSTANCE (lot), &v, 1, "title");
|
||||
qof_instance_set_dirty(QOF_INSTANCE(lot));
|
||||
gnc_lot_commit_edit(lot);
|
||||
g_value_unset (&v);
|
||||
}
|
||||
|
||||
void
|
||||
@ -482,6 +483,7 @@ gnc_lot_set_notes (GNCLot *lot, const char *str)
|
||||
qof_instance_set_kvp (QOF_INSTANCE (lot), &v, 1, "notes");
|
||||
qof_instance_set_dirty(QOF_INSTANCE(lot));
|
||||
gnc_lot_commit_edit(lot);
|
||||
g_value_unset (&v);
|
||||
}
|
||||
|
||||
/* ============================================================= */
|
||||
|
@ -361,6 +361,7 @@ GncInvoice *gncInvoiceCopy (const GncInvoice *from)
|
||||
qof_instance_get_kvp (QOF_INSTANCE (from), &v, 1, GNC_INVOICE_IS_CN);
|
||||
if (G_VALUE_HOLDS_INT64 (&v))
|
||||
qof_instance_set_kvp (QOF_INSTANCE (invoice), &v, 1, GNC_INVOICE_IS_CN);
|
||||
g_value_unset (&v);
|
||||
|
||||
invoice->terms = from->terms;
|
||||
gncBillTermIncRef (invoice->terms);
|
||||
@ -550,6 +551,7 @@ void gncInvoiceSetDocLink (GncInvoice *invoice, const char *doclink)
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
g_value_set_string (&v, doclink);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (invoice), &v, 1, GNC_INVOICE_DOCLINK);
|
||||
g_value_unset (&v);
|
||||
}
|
||||
qof_instance_set_dirty (QOF_INSTANCE(invoice));
|
||||
gncInvoiceCommitEdit (invoice);
|
||||
@ -573,6 +575,7 @@ void gncInvoiceSetIsCreditNote (GncInvoice *invoice, gboolean credit_note)
|
||||
g_value_init (&v, G_TYPE_INT64);
|
||||
g_value_set_int64 (&v, credit_note ? 1 : 0);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (invoice), &v, 1, GNC_INVOICE_IS_CN);
|
||||
g_value_unset (&v);
|
||||
mark_invoice (invoice);
|
||||
gncInvoiceCommitEdit (invoice);
|
||||
|
||||
@ -1131,12 +1134,12 @@ gboolean gncInvoiceGetActive (const GncInvoice *invoice)
|
||||
gboolean gncInvoiceGetIsCreditNote (const GncInvoice *invoice)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
gboolean retval;
|
||||
if (!invoice) return FALSE;
|
||||
qof_instance_get_kvp (QOF_INSTANCE(invoice), &v, 1, GNC_INVOICE_IS_CN);
|
||||
if (G_VALUE_HOLDS_INT64(&v) && g_value_get_int64 (&v))
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
retval = G_VALUE_HOLDS_INT64(&v) && g_value_get_int64 (&v);
|
||||
g_value_unset (&v);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
@ -317,6 +317,7 @@ void gncJobSetRate (GncJob *job, gnc_numeric rate)
|
||||
g_value_init (&v, GNC_TYPE_NUMERIC);
|
||||
g_value_set_boxed (&v, &rate);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (job), &v, 1, GNC_JOB_RATE);
|
||||
g_value_unset (&v);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -453,13 +454,14 @@ gnc_numeric gncJobGetRate (const GncJob *job)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
gnc_numeric *rate = NULL;
|
||||
gnc_numeric retval;
|
||||
if (!job) return gnc_numeric_zero ();
|
||||
qof_instance_get_kvp (QOF_INSTANCE (job), &v, 1, GNC_JOB_RATE);
|
||||
if (G_VALUE_HOLDS_BOXED (&v))
|
||||
rate = (gnc_numeric*)g_value_get_boxed (&v);
|
||||
if (rate)
|
||||
return *rate;
|
||||
return gnc_numeric_zero();
|
||||
retval = rate ? *rate : gnc_numeric_zero ();
|
||||
g_value_unset (&v);
|
||||
return retval;
|
||||
}
|
||||
|
||||
GncOwner * gncJobGetOwner (GncJob *job)
|
||||
|
@ -100,8 +100,9 @@ QofBackend::register_backend(const char* directory, const char* module_name)
|
||||
}
|
||||
|
||||
auto absdir = directory;
|
||||
auto pkgdir = gnc_path_get_pkglibdir ();
|
||||
if (!absdir || !g_path_is_absolute(absdir))
|
||||
absdir = gnc_path_get_pkglibdir ();
|
||||
absdir = pkgdir;
|
||||
auto fullpath = g_module_build_path (absdir, module_name);
|
||||
/* Darwin modules can have either .so or .dylib for a suffix */
|
||||
if (!g_file_test (fullpath, G_FILE_TEST_EXISTS) &&
|
||||
@ -114,6 +115,7 @@ QofBackend::register_backend(const char* directory, const char* module_name)
|
||||
}
|
||||
auto backend = g_module_open (fullpath, G_MODULE_BIND_LAZY);
|
||||
g_free (fullpath);
|
||||
g_free (pkgdir);
|
||||
if (!backend)
|
||||
{
|
||||
PINFO ("%s: %s\n", PROJECT_NAME, g_module_error ());
|
||||
|
Loading…
Reference in New Issue
Block a user