gnucash stable: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Sat May 10 21:15:40 EDT 2025
Updated via https://github.com/Gnucash/gnucash/commit/6941abee (commit)
via https://github.com/Gnucash/gnucash/commit/889a4dde (commit)
from https://github.com/Gnucash/gnucash/commit/ff759c26 (commit)
commit 6941abeea7f7720e1c879db283abc052336f8a33
Author: John Ralls <jralls at ceridwen.us>
Date: Sat May 10 18:14:48 2025 -0700
Mortgage Assistant: Handle daily payments
That case was left out of the payments-per-year calculation.
diff --git a/gnucash/gnome/assistant-loan.cpp b/gnucash/gnome/assistant-loan.cpp
index 60ca789f08..3b96e96080 100644
--- a/gnucash/gnome/assistant-loan.cpp
+++ b/gnucash/gnome/assistant-loan.cpp
@@ -2411,6 +2411,9 @@ periods_per_year( LoanAssistantData *ldd)
case PERIOD_YEAR:
ppy += 1.0 / multiplier;
break;
+ case PERIOD_DAY:
+ ppy = 365 / multiplier;
+ break;
case PERIOD_WEEK:
ppy += 52.0 / multiplier;
break;
commit 889a4dde956d623ed184fd9b1ce97e96d2998f66
Author: John Ralls <jralls at ceridwen.us>
Date: Sat May 10 15:12:14 2025 -0700
Mortgage assistant: Avoid crash when returning to the repayment page.
And as a side benefit don't leak signal handlers for the repGncFreq
changed signal.
The crash occured because gnc_frequency_setup_recurrence first calls
gnc_date_edit_set_gdate which emits a changed signal that, if it
wasn't the first call to loan_rep_prep would call
update_repayment_formula_cb and that would generate a new recurrences
list. But the still running gnc_frequency_setup_recurrence still had a
pointer to the old list and when it tried to manipulate it it would
crash.
This change disconnects the previous signal handler preventing the
list from being replaced.
diff --git a/gnucash/gnome/assistant-loan.cpp b/gnucash/gnome/assistant-loan.cpp
index 93da6017cb..60ca789f08 100644
--- a/gnucash/gnome/assistant-loan.cpp
+++ b/gnucash/gnome/assistant-loan.cpp
@@ -1339,6 +1339,13 @@ static void
loan_rep_prep( GtkAssistant *assistant, gpointer user_data )
{
LoanAssistantData *ldd = static_cast<LoanAssistantData*> (user_data);
+ static gulong date_changed_handler_id = 0;
+
+ if (date_changed_handler_id)
+ {
+ g_signal_handler_disconnect(ldd->repGncFreq, date_changed_handler_id);
+ date_changed_handler_id = 0;
+ }
ldd->ld.repAmount = loan_get_pmt_formula(ldd);
@@ -1356,8 +1363,8 @@ loan_rep_prep( GtkAssistant *assistant, gpointer user_data )
(gpointer) loan_rep_page_valid_cb, ldd );
gnc_frequency_setup_recurrence(ldd->repGncFreq, ldd->ld.repayment_schedule,
ldd->ld.repStartDate);
- g_signal_connect (ldd->repGncFreq, "changed",
- G_CALLBACK (update_repayment_formula_cb), ldd);
+ date_changed_handler_id = g_signal_connect (ldd->repGncFreq, "changed",
+ G_CALLBACK (update_repayment_formula_cb), ldd);
g_signal_handlers_unblock_by_func( ldd->repGncFreq,
(gpointer) loan_rep_page_valid_cb, ldd );
diff --git a/libgnucash/engine/Recurrence.cpp b/libgnucash/engine/Recurrence.cpp
index e4f378a0c2..47f5439cf8 100644
--- a/libgnucash/engine/Recurrence.cpp
+++ b/libgnucash/engine/Recurrence.cpp
@@ -892,7 +892,6 @@ recurrenceListCmp(GList *a, GList *b)
void
recurrenceListFree(GList **recurrences)
{
- g_list_foreach(*recurrences, (GFunc)g_free, NULL);
- g_list_free(*recurrences);
+ g_list_free_full(*recurrences, (GDestroyNotify)g_free);
*recurrences = NULL;
}
Summary of changes:
gnucash/gnome/assistant-loan.cpp | 14 ++++++++++++--
libgnucash/engine/Recurrence.cpp | 3 +--
2 files changed, 13 insertions(+), 4 deletions(-)
More information about the gnucash-changes
mailing list