gnucash maint: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Sat Aug 21 11:46:01 EDT 2021
Updated via https://github.com/Gnucash/gnucash/commit/c398bef5 (commit)
via https://github.com/Gnucash/gnucash/commit/7e41efc2 (commit)
via https://github.com/Gnucash/gnucash/commit/028bf982 (commit)
from https://github.com/Gnucash/gnucash/commit/ff2ceb11 (commit)
commit c398bef59719c2c53ede8d4ca4d680ee48e613bf
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Aug 21 00:29:41 2021 +0800
[window-main-summarybar] move mnemonic to get_total_mode_label
avoiding static char* reassignment
diff --git a/gnucash/gnome-utils/window-main-summarybar.c b/gnucash/gnome-utils/window-main-summarybar.c
index 4765ea62a..503dc703c 100644
--- a/gnucash/gnome-utils/window-main-summarybar.c
+++ b/gnucash/gnome-utils/window-main-summarybar.c
@@ -296,11 +296,14 @@ gnc_ui_accounts_recurse (Account *parent, GList **currency_list,
}
static char*
-get_total_mode_label(const char *mnemonic, int total_mode)
+get_total_mode_label (GNCCurrencyAcc *currency_accum)
{
+ const char *mnemonic = gnc_commodity_get_nice_symbol (currency_accum->currency);
char *label_str;
+ if (mnemonic == NULL)
+ mnemonic = "";
// i.e., "$, grand total," [profits: $12,345.67, assets: $23,456.78]
- switch (total_mode)
+ switch (currency_accum->total_mode)
{
case TOTAL_CURR_TOTAL:
label_str = g_strdup_printf( _("%s, Total:"), mnemonic );
@@ -395,15 +398,10 @@ gnc_main_window_summary_refresh (GNCMainSummary * summary)
gtk_list_store_clear(summary->datamodel);
for (current = g_list_first(currency_list); current; current = g_list_next(current))
{
- const char *mnemonic;
gchar *total_mode_label;
currency_accum = current->data;
- mnemonic = gnc_commodity_get_nice_symbol (currency_accum->currency);
- if (mnemonic == NULL)
- mnemonic = "";
-
xaccSPrintAmount(asset_amount_string,
currency_accum->assets,
gnc_commodity_print_info(currency_accum->currency, TRUE));
@@ -413,7 +411,7 @@ gnc_main_window_summary_refresh (GNCMainSummary * summary)
gnc_commodity_print_info(currency_accum->currency, TRUE));
gtk_list_store_append(summary->datamodel, &iter);
- total_mode_label = get_total_mode_label(mnemonic, currency_accum->total_mode);
+ total_mode_label = get_total_mode_label (currency_accum);
gtk_list_store_set(summary->datamodel, &iter,
COLUMN_MNEMONIC_TYPE, total_mode_label,
COLUMN_ASSETS, _("Net Assets:"),
commit 7e41efc23203a681156bd71c269a35d04650f480
Merge: ff2ceb111 028bf9826
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Aug 20 21:23:35 2021 +0800
Merge branch 'maint-speedup-and-leaks' into maint #1109
Speedup xaccSplitGetOtherSplit
commit 028bf9826bdcf295c238e1c6b61e5cc50154b26c
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Aug 14 11:25:19 2021 +0800
[Split] xaccSplitGetOtherSplit don't test book trading-accts
don't test trading-acct property when finding other split.
diff --git a/libgnucash/engine/Split.c b/libgnucash/engine/Split.c
index e27c1ba96..9392ddd33 100644
--- a/libgnucash/engine/Split.c
+++ b/libgnucash/engine/Split.c
@@ -2077,45 +2077,27 @@ xaccSplitMergePeerSplits (Split *split, const Split *other_split)
Split *
xaccSplitGetOtherSplit (const Split *split)
{
- int i;
Transaction *trans;
- int count, num_splits;
Split *other = NULL;
- gboolean lot_split;
- gboolean trading_accts;
if (!split) return NULL;
trans = split->parent;
if (!trans) return NULL;
- trading_accts = xaccTransUseTradingAccounts (trans);
- num_splits = xaccTransCountSplits(trans);
- count = num_splits;
- lot_split = qof_instance_has_slot(QOF_INSTANCE (split), "lot-split");
- if (!lot_split && !trading_accts && (2 != count)) return NULL;
-
- for (i = 0; i < num_splits; i++)
+ for (GList *n = xaccTransGetSplitList (trans); n; n = n->next)
{
- Split *s = xaccTransGetSplit(trans, i);
- if (s == split)
- {
- --count;
- continue;
- }
- if (qof_instance_has_slot (QOF_INSTANCE (s), "lot-split"))
- {
- --count;
+ Split *s = n->data;
+ if ((s == split) ||
+ (xaccAccountGetType (xaccSplitGetAccount (s)) == ACCT_TYPE_TRADING) ||
+ (qof_instance_has_slot (QOF_INSTANCE (s), "lot-split")))
continue;
- }
- if (trading_accts &&
- xaccAccountGetType(xaccSplitGetAccount(s)) == ACCT_TYPE_TRADING)
- {
- --count;
- continue;
- }
+
+ if (other)
+ return NULL;
+
other = s;
}
- return (1 == count) ? other : NULL;
+ return other;
}
/********************************************************************\
Summary of changes:
gnucash/gnome-utils/window-main-summarybar.c | 14 +++++-----
libgnucash/engine/Split.c | 38 ++++++++--------------------
2 files changed, 16 insertions(+), 36 deletions(-)
More information about the gnucash-changes
mailing list