gnucash stable: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Sat Sep 20 21:17:38 EDT 2025
Updated via https://github.com/Gnucash/gnucash/commit/e753555c (commit)
via https://github.com/Gnucash/gnucash/commit/4c09a0fe (commit)
from https://github.com/Gnucash/gnucash/commit/ebcd670a (commit)
commit e753555c2f53cad898a9f44e46be5cff47ab906e
Merge: ebcd670ab5 4c09a0feee
Author: John Ralls <jralls at ceridwen.us>
Date: Sat Sep 20 18:17:11 2025 -0700
Merge John Ralls's 'bug799249' into stable
commit 4c09a0feee698855f095f9729a4856033cbd0522
Author: John Ralls <jralls at ceridwen.us>
Date: Tue Jul 22 10:53:20 2025 -0700
Bug 799249 - Crash while switch to recently opened file
Null the model's root account so that it can't be traversed after
it has been disposed.
diff --git a/gnucash/gnome-utils/gnc-tree-model-account.c b/gnucash/gnome-utils/gnc-tree-model-account.c
index 8aa17073b3..d038ab3857 100644
--- a/gnucash/gnome-utils/gnc-tree-model-account.c
+++ b/gnucash/gnome-utils/gnc-tree-model-account.c
@@ -199,17 +199,11 @@ gnc_tree_model_account_init (GncTreeModelAccount *model)
static void
gnc_tree_model_account_finalize (GObject *object)
{
- GncTreeModelAccount *model;
-
g_return_if_fail (object != NULL);
g_return_if_fail (GNC_IS_TREE_MODEL_ACCOUNT(object));
ENTER("model %p", object);
- model = GNC_TREE_MODEL_ACCOUNT(object);
-
- model->book = NULL;
-
G_OBJECT_CLASS(gnc_tree_model_account_parent_class)->finalize (object);
LEAVE(" ");
}
@@ -242,6 +236,9 @@ gnc_tree_model_account_dispose (GObject *object)
gnc_tree_model_account_update_color,
model);
+ model->book = NULL;
+ model->root = NULL;
+
G_OBJECT_CLASS(gnc_tree_model_account_parent_class)->dispose (object);
LEAVE(" ");
}
@@ -429,6 +426,12 @@ gnc_tree_model_account_get_iter (GtkTreeModel *tree_model,
model = GNC_TREE_MODEL_ACCOUNT(tree_model);
+ if (!model->root)
+ {
+ LEAVE("No root account");
+ return FALSE;
+ }
+
if (gtk_tree_path_get_depth (path) <= 0)
{
LEAVE("bad depth");
@@ -1409,7 +1412,7 @@ gnc_tree_model_account_event_handler (QofInstance *entity,
Account *account, *parent;
g_return_if_fail (model); /* Required */
-
+ g_return_if_fail (model->root); /* Either disposed or not initialized. */
if (!GNC_IS_ACCOUNT(entity))
return;
diff --git a/gnucash/gnome-utils/gnc-tree-view-account.c b/gnucash/gnome-utils/gnc-tree-view-account.c
index a58b6cff03..6938399310 100644
--- a/gnucash/gnome-utils/gnc-tree-view-account.c
+++ b/gnucash/gnome-utils/gnc-tree-view-account.c
@@ -58,6 +58,7 @@
static QofLogModule log_module = GNC_MOD_GUI;
/** Declarations *********************************************************/
+static void gnc_tree_view_account_destroy (GtkWidget *widget);
static void gnc_tree_view_account_finalize (GObject *object);
static gboolean gnc_tree_view_search_compare (GtkTreeModel *model, gint column,
const gchar *key, GtkTreeIter *iter, gpointer search_data);
@@ -129,10 +130,11 @@ G_DEFINE_TYPE(GncTreeViewAccount, gnc_tree_view_account, GNC_TYPE_TREE_VIEW)
static void
gnc_tree_view_account_class_init (GncTreeViewAccountClass *klass)
{
- GObjectClass *o_class;
-
+ GObjectClass *o_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *w_class = GTK_WIDGET_CLASS (klass);
/* GObject signals */
- o_class = G_OBJECT_CLASS (klass);
+
+ w_class->destroy = gnc_tree_view_account_destroy;
o_class->finalize = gnc_tree_view_account_finalize;
gnc_hook_add_dangler(HOOK_CURRENCY_CHANGED,
@@ -167,6 +169,21 @@ gnc_tree_view_account_init (GncTreeViewAccount *view)
gnc_init_account_view_info(&view->avi);
}
+static void
+gnc_tree_view_account_destroy (GtkWidget *widget)
+{
+
+ GtkTreeView *view = GTK_TREE_VIEW (widget);
+ if (view)
+ {
+ GtkTreeModel *model;
+ model = gtk_tree_view_get_model(view);
+ g_object_run_dispose (G_OBJECT (model));
+ gtk_tree_view_set_model(view, NULL);
+ }
+ GTK_WIDGET_CLASS(gnc_tree_view_account_parent_class)->destroy(widget);
+}
+
static void
gnc_tree_view_account_finalize (GObject *object)
{
diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.cpp b/gnucash/gnome/gnc-plugin-page-account-tree.cpp
index 659c2345d4..eb7f8c149b 100644
--- a/gnucash/gnome/gnc-plugin-page-account-tree.cpp
+++ b/gnucash/gnome/gnc-plugin-page-account-tree.cpp
@@ -770,6 +770,8 @@ gnc_plugin_page_account_tree_destroy_widget (GncPluginPage *plugin_page)
// Save account filter state information to account section
gnc_tree_view_account_save_filter (GNC_TREE_VIEW_ACCOUNT(priv->tree_view), &priv->fd,
gnc_state_get_current(), gnc_tree_view_get_state_section (GNC_TREE_VIEW(priv->tree_view)));
+ g_object_unref(G_OBJECT(priv->tree_view));
+ priv->tree_view = NULL;
// Destroy the filter override hash table
g_hash_table_destroy(priv->fd.filter_override);
@@ -780,10 +782,10 @@ gnc_plugin_page_account_tree_destroy_widget (GncPluginPage *plugin_page)
// Remove the page focus idle function if present
g_idle_remove_by_data (plugin_page);
- if (priv->widget)
+ if (priv->tree_view)
{
- g_object_unref(G_OBJECT(priv->widget));
- priv->widget = NULL;
+ gtk_widget_destroy(GTK_WIDGET(priv->tree_view));
+ priv->tree_view = NULL;
}
if (priv->component_id)
diff --git a/gnucash/report/commodity-utilities.scm b/gnucash/report/commodity-utilities.scm
index 5e66551175..b23bd54277 100644
--- a/gnucash/report/commodity-utilities.scm
+++ b/gnucash/report/commodity-utilities.scm
@@ -590,8 +590,8 @@
;; no, create sub-alist from scratch
(let ((pair (list txn-comm (cons (gnc:make-value-collector)
(gnc:make-value-collector)))))
- ((caadr pair) 'add value-amt)
- ((cdadr pair) 'add share-amt)
+ ((caadr pair) 'add (- value-amt))
+ ((cdadr pair) 'add (- share-amt))
;; and add the new sub-alist to sumlist.
(loop (cdr comm-splits)
(cons (list acc-comm (list pair)) sumlist)))))))))))
Summary of changes:
gnucash/gnome-utils/gnc-tree-model-account.c | 17 ++++++++++-------
gnucash/gnome-utils/gnc-tree-view-account.c | 23 ++++++++++++++++++++---
gnucash/gnome/gnc-plugin-page-account-tree.cpp | 8 +++++---
3 files changed, 35 insertions(+), 13 deletions(-)
More information about the gnucash-changes
mailing list