gnucash stable: Mostly revert "Bug 799249 - Crash while switch to recently opened file"
John Ralls
jralls at code.gnucash.org
Sun Oct 12 14:14:29 EDT 2025
Updated via https://github.com/Gnucash/gnucash/commit/fb6e8d92 (commit)
from https://github.com/Gnucash/gnucash/commit/01f0d252 (commit)
commit fb6e8d927ef74921fd68e3f935a4375030fe97d5
Author: John Ralls <jralls at ceridwen.us>
Date: Sun Oct 12 10:03:37 2025 -0700
Mostly revert "Bug 799249 - Crash while switch to recently opened file"
Leaving only nulling out the GncTreeModelAccount's root account pointer in its dispose
function.
diff --git a/gnucash/gnome-utils/gnc-tree-model-account.c b/gnucash/gnome-utils/gnc-tree-model-account.c
index d038ab3857..dfaaabb8d3 100644
--- a/gnucash/gnome-utils/gnc-tree-model-account.c
+++ b/gnucash/gnome-utils/gnc-tree-model-account.c
@@ -199,11 +199,17 @@ 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(" ");
}
@@ -236,9 +242,7 @@ 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(" ");
}
@@ -426,12 +430,6 @@ 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");
@@ -1412,7 +1410,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 6938399310..a58b6cff03 100644
--- a/gnucash/gnome-utils/gnc-tree-view-account.c
+++ b/gnucash/gnome-utils/gnc-tree-view-account.c
@@ -58,7 +58,6 @@
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);
@@ -130,11 +129,10 @@ 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 = G_OBJECT_CLASS (klass);
- GtkWidgetClass *w_class = GTK_WIDGET_CLASS (klass);
- /* GObject signals */
+ GObjectClass *o_class;
- w_class->destroy = gnc_tree_view_account_destroy;
+ /* GObject signals */
+ o_class = G_OBJECT_CLASS (klass);
o_class->finalize = gnc_tree_view_account_finalize;
gnc_hook_add_dangler(HOOK_CURRENCY_CHANGED,
@@ -169,21 +167,6 @@ 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 37ec47fccc..4a7fb6a468 100644
--- a/gnucash/gnome/gnc-plugin-page-account-tree.cpp
+++ b/gnucash/gnome/gnc-plugin-page-account-tree.cpp
@@ -780,10 +780,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->tree_view)
+ if (priv->widget)
{
- gtk_widget_destroy(GTK_WIDGET(priv->tree_view));
- priv->tree_view = NULL;
+ g_object_unref(G_OBJECT(priv->widget));
+ priv->widget = NULL;
}
if (priv->component_id)
@@ -792,6 +792,7 @@ gnc_plugin_page_account_tree_destroy_widget (GncPluginPage *plugin_page)
priv->component_id = 0;
}
+ priv->tree_view = NULL;
LEAVE("widget destroyed");
}
Summary of changes:
gnucash/gnome-utils/gnc-tree-model-account.c | 16 +++++++---------
gnucash/gnome-utils/gnc-tree-view-account.c | 23 +++--------------------
gnucash/gnome/gnc-plugin-page-account-tree.cpp | 7 ++++---
3 files changed, 14 insertions(+), 32 deletions(-)
More information about the gnucash-changes
mailing list