Merge Chris Lam's 'maint-progress1' into maint.

This commit is contained in:
John Ralls 2022-02-28 13:51:45 -08:00
commit 831b25f8f8
11 changed files with 33 additions and 84 deletions

View File

@ -402,11 +402,9 @@ gnc_commodity *
gnc_currency_edit_get_currency (GNCCurrencyEdit *gce)
{
gnc_commodity *commodity;
const char *fullname;
char *mnemonic, *name;
GtkTreeModel *model;
GtkTreeIter iter;
GValue value = { 0 };
g_return_val_if_fail(gce != NULL, NULL);
g_return_val_if_fail(GNC_IS_CURRENCY_EDIT(gce), NULL);
@ -414,10 +412,7 @@ gnc_currency_edit_get_currency (GNCCurrencyEdit *gce)
if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(gce), &iter))
{
model = gtk_combo_box_get_model(GTK_COMBO_BOX(gce));
gtk_tree_model_get_value(model, &iter, 0, &value);
fullname = g_value_get_string(&value);
mnemonic = g_strdup(fullname);
g_value_unset(&value);
gtk_tree_model_get (model, &iter, 0, &mnemonic, -1);
name = strchr(mnemonic, ' ');
if (name != NULL)

View File

@ -283,18 +283,14 @@ gnc_plugin_update_actions (GtkActionGroup *action_group,
gboolean value)
{
GtkAction *action;
GValue gvalue = { 0 };
gint i;
g_value_init (&gvalue, G_TYPE_BOOLEAN);
g_value_set_boolean (&gvalue, value);
for (i = 0; action_names[i]; i++)
{
action = gtk_action_group_get_action (action_group, action_names[i]);
if (action)
{
g_object_set_property (G_OBJECT(action), property_name, &gvalue);
g_object_set (G_OBJECT(action), property_name, value, NULL);
}
else
{
@ -303,7 +299,6 @@ gnc_plugin_update_actions (GtkActionGroup *action_group,
g_list_length(gtk_action_group_list_actions(action_group)));
}
}
g_value_unset (&gvalue);
}

View File

@ -108,13 +108,9 @@ GncBudget *
gnc_tree_model_budget_get_budget(GtkTreeModel *tm, GtkTreeIter *iter)
{
GncBudget *bgt;
GValue gv = { 0 };
GncGUID *guid;
gtk_tree_model_get_value(tm, iter, BUDGET_GUID_COLUMN, &gv);
guid = (GncGUID *) g_value_get_pointer(&gv);
g_value_unset(&gv);
gtk_tree_model_get (tm, iter, BUDGET_GUID_COLUMN, &guid, -1);
bgt = gnc_budget_lookup(guid, gnc_get_current_book());
return bgt;
}
@ -123,7 +119,6 @@ gboolean
gnc_tree_model_budget_get_iter_for_budget(GtkTreeModel *tm, GtkTreeIter *iter,
GncBudget *bgt)
{
GValue gv = { 0 };
const GncGUID *guid1;
GncGUID *guid2;
@ -134,9 +129,7 @@ gnc_tree_model_budget_get_iter_for_budget(GtkTreeModel *tm, GtkTreeIter *iter,
return FALSE;
while (gtk_list_store_iter_is_valid(GTK_LIST_STORE(tm), iter))
{
gtk_tree_model_get_value(tm, iter, BUDGET_GUID_COLUMN, &gv);
guid2 = (GncGUID *) g_value_get_pointer(&gv);
g_value_unset(&gv);
gtk_tree_model_get (tm, iter, BUDGET_GUID_COLUMN, &guid2, -1);
if (guid_equal(guid1, guid2))
return TRUE;

View File

@ -1164,8 +1164,6 @@ static Split *
gtv_sr_get_this_split (GncTreeViewSplitReg *view, Transaction *trans)
{
GncTreeModelSplitReg *model;
int i;
Split *split = NULL;
Account *anchor;
model = gnc_tree_view_split_reg_get_model_from_view (view);
@ -1178,7 +1176,9 @@ gtv_sr_get_this_split (GncTreeViewSplitReg *view, Transaction *trans)
return gnc_tree_model_split_get_blank_split (model);
}
for (i = 0; (split = xaccTransGetSplit (trans, i)); i++) {
for (GList *n = xaccTransGetSplitList (trans); n; n = n->next)
{
Split *split = n->data;
if (anchor == xaccSplitGetAccount (split))
return split;
}
@ -1210,8 +1210,7 @@ gtv_sr_get_split_pair (GncTreeViewSplitReg *view, Transaction *trans, Split **os
}
else
{
int i;
Split *s, *first_split;
Split *first_split;
first_split = xaccTransGetSplit (trans, 0);
@ -1219,8 +1218,9 @@ gtv_sr_get_split_pair (GncTreeViewSplitReg *view, Transaction *trans, Split **os
return FALSE;
else // two split trans
{
for (i = 0; (s = xaccTransGetSplit (trans, i)); i++)
for (GList *n = xaccTransGetSplitList (trans); n; n = n->next)
{
Split *s = n->data;
if (anchor == xaccSplitGetAccount (s))
{
*split = s;
@ -1241,13 +1241,12 @@ gtv_sr_get_split_pair (GncTreeViewSplitReg *view, Transaction *trans, Split **os
static gboolean
gtv_sr_get_imbalance (Transaction *trans)
{
int i;
Split *split = NULL;
const gchar *acc_name;
const gchar *prefix = _("Imbalance");
for (i = 0; (split = xaccTransGetSplit (trans, i)); i++)
for (GList *n = xaccTransGetSplitList (trans); n; n = n->next)
{
Split *split = n->data;
if (xaccSplitGetAccount (split) != NULL)
{
acc_name = xaccAccountGetName (xaccSplitGetAccount (split));

View File

@ -579,7 +579,6 @@ gnc_simple_combo_get_value (GtkComboBox *cbox)
{
GtkTreeIter iter;
GtkTreeModel *model;
GValue value = { 0 };
gpointer retval;
if (!cbox) return NULL;
@ -587,9 +586,7 @@ gnc_simple_combo_get_value (GtkComboBox *cbox)
model = gtk_combo_box_get_model (cbox);
if (!gtk_combo_box_get_active_iter (cbox, &iter))
return NULL;
gtk_tree_model_get_value (model, &iter, 1, &value);
retval = g_value_get_pointer (&value);
g_value_unset (&value);
gtk_tree_model_get (model, &iter, 1, &retval, -1);
return retval;
}
@ -610,28 +607,25 @@ gnc_simple_combo_set_value (GtkComboBox *cbox, gpointer data)
while (valid_iter)
{
GValue value = { 0 };
gpointer ptr;
gtk_tree_model_get_value (model, &iter, 1, &value);
gtk_tree_model_get (model, &iter, 1, &ptr, -1);
if (lsd && lsd->is_equal) // A specific comparator function was set
{
if ((lsd->is_equal)(g_value_get_pointer(&value), data))
if ((lsd->is_equal)(ptr, data))
{
gtk_combo_box_set_active_iter (cbox, &iter);
g_value_unset (&value);
return;
}
}
else // No specific comparator function set, use generic pointer comparison instead
{
if (g_value_get_pointer(&value) == data)
if (ptr == 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);
}
}

View File

@ -810,16 +810,13 @@ static void print_date (GtkTreeViewColumn *tree_column,
GtkTreeIter *iter,
gpointer data)
{
GValue value = { 0 };
time64 doc_date_time;
gchar *doc_date_str = g_strdup (_("Open"));
gint col = GPOINTER_TO_INT(data);
g_return_if_fail (cell && iter && tree_model);
gtk_tree_model_get_value (tree_model, iter, col, &value);
doc_date_time = (time64) g_value_get_int64 (&value);
g_value_unset (&value);
gtk_tree_model_get (tree_model, iter, col, &doc_date_time, -1);
if (doc_date_time != G_MAXINT64) /* assumes INT64_MAX represents an invalid date/time */
{

View File

@ -339,14 +339,11 @@ calculate_selected_total_helper (GtkTreeModel *model,
{
gnc_numeric *subtotal = (gnc_numeric*) data;
gnc_numeric cur_val;
GValue value = { 0 };
GNCLot *lot;
Account *acct;
gnc_commodity *currency;
gtk_tree_model_get_value (model, iter, 5, &value);
lot = (GNCLot *) g_value_get_pointer (&value);
g_value_unset (&value);
gtk_tree_model_get (model, iter, 5, &lot, -1);
/* Find the amount's currency to determine the required precision */
acct = gnc_lot_get_account (lot);
@ -413,13 +410,10 @@ gnc_payment_dialog_highlight_documents (PaymentWindow *pw)
{
do
{
GValue value = { 0 };
GNCLot *lot;
GList *li_node;
gtk_tree_model_get_value (model, &iter, 5, &value);
lot = (GNCLot *) g_value_get_pointer (&value);
g_value_unset (&value);
gtk_tree_model_get (model, &iter, 5, &lot, -1);
if (!lot)
continue; /* Lot has been deleted behind our back... */
@ -949,11 +943,8 @@ get_selected_lots (GtkTreeModel *model,
{
GList **return_list = data;
GNCLot *lot;
GValue value = { 0 };
gtk_tree_model_get_value (model, iter, 5, &value);
lot = (GNCLot *) g_value_get_pointer (&value);
g_value_unset (&value);
gtk_tree_model_get (model, iter, 5, &lot, -1);
if (lot)
*return_list = g_list_insert_sorted (*return_list, lot, (GCompareFunc)gncOwnerLotsSortFunc);
@ -1186,16 +1177,13 @@ static void print_date (G_GNUC_UNUSED GtkTreeViewColumn *tree_column,
GtkTreeIter *iter,
G_GNUC_UNUSED gpointer data)
{
GValue value = { 0 };
time64 doc_date_time;
gchar *doc_date_str;
g_return_if_fail (cell && iter && tree_model);
gtk_tree_model_get_value (tree_model, iter, 0, &value);
doc_date_time = (time64) g_value_get_int64 (&value);
g_value_unset (&value);
gtk_tree_model_get (tree_model, iter, 0, &doc_date_time, -1);
doc_date_str = qof_print_date (doc_date_time);
g_object_set (G_OBJECT (cell), "text", doc_date_str, NULL);
g_free (doc_date_str);

View File

@ -338,7 +338,6 @@ gnc_plugin_page_owner_tree_new (GncOwnerType owner_type)
GtkActionGroup *action_group;
GtkAction *action;
GValue gvalue = { 0 };
gint i;
g_return_val_if_fail( (owner_type != GNC_OWNER_UNDEFINED)
@ -365,15 +364,14 @@ gnc_plugin_page_owner_tree_new (GncOwnerType owner_type)
/* Hide menu and toolbar items that are not relevant for the active owner list */
action_group = gnc_plugin_page_get_action_group(GNC_PLUGIN_PAGE(plugin_page));
g_value_init (&gvalue, G_TYPE_BOOLEAN);
for (i = 0; action_owners[i].action_name; i++)
{
action = gtk_action_group_get_action (action_group, action_owners[i].action_name);
g_value_set_boolean (&gvalue, (priv->owner_type == action_owners[i].owner_type) );
g_object_set_property (G_OBJECT(action), "visible", &gvalue);
g_object_set (G_OBJECT(action),
"visible", (priv->owner_type == action_owners[i].owner_type),
NULL);
}
g_value_unset (&gvalue);
LEAVE("new %s tree page %p", gncOwnerTypeToQofIdType(owner_type), plugin_page);
return GNC_PLUGIN_PAGE(plugin_page);
}

View File

@ -641,12 +641,9 @@ static Split *
gnc_find_split_in_trans_by_memo (Transaction *trans, const char *memo,
gboolean unit_price)
{
int i = 0;
Split *split;
while ((split = xaccTransGetSplit(trans, i)) != NULL)
for (GList *n = xaccTransGetSplitList (trans); n; n = n->next)
{
i++;
Split *split = n->data;
if (unit_price)
{
gnc_numeric price = xaccSplitGetSharePrice (split);
@ -899,21 +896,19 @@ gnc_split_register_auto_completion (SplitRegister *reg,
gnc_split_register_get_default_account (reg);
gnc_commodity *trans_cmdty = xaccTransGetCurrency(trans);
gnc_commodity *acct_cmdty = xaccAccountGetCommodity(default_account);
Split *s;
int i = 0;
if (gnc_commodity_is_currency(acct_cmdty) &&
!gnc_commodity_equal(trans_cmdty, acct_cmdty))
xaccTransSetCurrency(trans, acct_cmdty);
while ((s = xaccTransGetSplit(trans, i)) != NULL)
for (GList *n = xaccTransGetSplitList (trans); n; n = n->next)
{
Split *s = n->data;
if (default_account == xaccSplitGetAccount(s))
{
blank_split = s;
info->blank_split_guid = *xaccSplitGetGUID(blank_split);
break;
}
i++;
}
}

View File

@ -239,9 +239,6 @@ _find_split_with_parent_txn (gconstpointer a, gconstpointer b)
static void add_quickfill_completions (TableLayout* layout, Transaction* trans,
Split* split, gboolean has_last_num)
{
Split* s;
int i = 0;
gnc_quickfill_cell_add_completion (
(QuickFillCell*) gnc_table_layout_get_cell (layout, DESC_CELL),
xaccTransGetDescription (trans));
@ -255,12 +252,12 @@ static void add_quickfill_completions (TableLayout* layout, Transaction* trans,
(NumCell*) gnc_table_layout_get_cell (layout, NUM_CELL),
gnc_get_num_action (trans, split));
while ((s = xaccTransGetSplit (trans, i)) != NULL)
for (GList *n = xaccTransGetSplitList (trans); n; n = n->next)
{
Split *s = n->data;
gnc_quickfill_cell_add_completion (
(QuickFillCell*) gnc_table_layout_get_cell (layout, MEMO_CELL),
xaccSplitGetMemo (s));
i++;
}
}

View File

@ -1114,14 +1114,13 @@ gnc_split_register_change_blank_split_ref (SplitRegister* reg, Split* split)
gnc_get_current_book ());
Split* pref_split = NULL; // has the same account as incoming split
Split* other_split = NULL; // other split
Split* s;
Account* blank_split_account = xaccSplitGetAccount (current_blank_split);
Transaction* trans = xaccSplitGetParent (split);
int i = 0;
// loop through splitlist looking for splits other than the blank_split
while ((s = xaccTransGetSplit (trans, i)) != NULL)
for (GList *n = xaccTransGetSplitList (trans); n; n = n->next)
{
Split *s = n->data;
if (s != current_blank_split)
{
if (blank_split_account == xaccSplitGetAccount (s))
@ -1129,7 +1128,6 @@ gnc_split_register_change_blank_split_ref (SplitRegister* reg, Split* split)
else
other_split = s; // any other split
}
i++;
}
// now change the saved blank split reference
if (pref_split != NULL)