Skip to content

Commit fb6e8d9

Browse files
committed
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.
1 parent 01f0d25 commit fb6e8d9

File tree

3 files changed

+14
-32
lines changed

3 files changed

+14
-32
lines changed

gnucash/gnome-utils/gnc-tree-model-account.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,17 @@ gnc_tree_model_account_init (GncTreeModelAccount *model)
199199
static void
200200
gnc_tree_model_account_finalize (GObject *object)
201201
{
202+
GncTreeModelAccount *model;
203+
202204
g_return_if_fail (object != NULL);
203205
g_return_if_fail (GNC_IS_TREE_MODEL_ACCOUNT(object));
204206

205207
ENTER("model %p", object);
206208

209+
model = GNC_TREE_MODEL_ACCOUNT(object);
210+
211+
model->book = NULL;
212+
207213
G_OBJECT_CLASS(gnc_tree_model_account_parent_class)->finalize (object);
208214
LEAVE(" ");
209215
}
@@ -236,9 +242,7 @@ gnc_tree_model_account_dispose (GObject *object)
236242
gnc_tree_model_account_update_color,
237243
model);
238244

239-
model->book = NULL;
240245
model->root = NULL;
241-
242246
G_OBJECT_CLASS(gnc_tree_model_account_parent_class)->dispose (object);
243247
LEAVE(" ");
244248
}
@@ -426,12 +430,6 @@ gnc_tree_model_account_get_iter (GtkTreeModel *tree_model,
426430

427431
model = GNC_TREE_MODEL_ACCOUNT(tree_model);
428432

429-
if (!model->root)
430-
{
431-
LEAVE("No root account");
432-
return FALSE;
433-
}
434-
435433
if (gtk_tree_path_get_depth (path) <= 0)
436434
{
437435
LEAVE("bad depth");
@@ -1412,7 +1410,7 @@ gnc_tree_model_account_event_handler (QofInstance *entity,
14121410
Account *account, *parent;
14131411

14141412
g_return_if_fail (model); /* Required */
1415-
g_return_if_fail (model->root); /* Either disposed or not initialized. */
1413+
14161414
if (!GNC_IS_ACCOUNT(entity))
14171415
return;
14181416

gnucash/gnome-utils/gnc-tree-view-account.c

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
static QofLogModule log_module = GNC_MOD_GUI;
5959

6060
/** Declarations *********************************************************/
61-
static void gnc_tree_view_account_destroy (GtkWidget *widget);
6261
static void gnc_tree_view_account_finalize (GObject *object);
6362
static gboolean gnc_tree_view_search_compare (GtkTreeModel *model, gint column,
6463
const gchar *key, GtkTreeIter *iter, gpointer search_data);
@@ -130,11 +129,10 @@ G_DEFINE_TYPE(GncTreeViewAccount, gnc_tree_view_account, GNC_TYPE_TREE_VIEW)
130129
static void
131130
gnc_tree_view_account_class_init (GncTreeViewAccountClass *klass)
132131
{
133-
GObjectClass *o_class = G_OBJECT_CLASS (klass);
134-
GtkWidgetClass *w_class = GTK_WIDGET_CLASS (klass);
135-
/* GObject signals */
132+
GObjectClass *o_class;
136133

137-
w_class->destroy = gnc_tree_view_account_destroy;
134+
/* GObject signals */
135+
o_class = G_OBJECT_CLASS (klass);
138136
o_class->finalize = gnc_tree_view_account_finalize;
139137

140138
gnc_hook_add_dangler(HOOK_CURRENCY_CHANGED,
@@ -169,21 +167,6 @@ gnc_tree_view_account_init (GncTreeViewAccount *view)
169167
gnc_init_account_view_info(&view->avi);
170168
}
171169

172-
static void
173-
gnc_tree_view_account_destroy (GtkWidget *widget)
174-
{
175-
176-
GtkTreeView *view = GTK_TREE_VIEW (widget);
177-
if (view)
178-
{
179-
GtkTreeModel *model;
180-
model = gtk_tree_view_get_model(view);
181-
g_object_run_dispose (G_OBJECT (model));
182-
gtk_tree_view_set_model(view, NULL);
183-
}
184-
GTK_WIDGET_CLASS(gnc_tree_view_account_parent_class)->destroy(widget);
185-
}
186-
187170
static void
188171
gnc_tree_view_account_finalize (GObject *object)
189172
{

gnucash/gnome/gnc-plugin-page-account-tree.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -780,10 +780,10 @@ gnc_plugin_page_account_tree_destroy_widget (GncPluginPage *plugin_page)
780780
// Remove the page focus idle function if present
781781
g_idle_remove_by_data (plugin_page);
782782

783-
if (priv->tree_view)
783+
if (priv->widget)
784784
{
785-
gtk_widget_destroy(GTK_WIDGET(priv->tree_view));
786-
priv->tree_view = NULL;
785+
g_object_unref(G_OBJECT(priv->widget));
786+
priv->widget = NULL;
787787
}
788788

789789
if (priv->component_id)
@@ -792,6 +792,7 @@ gnc_plugin_page_account_tree_destroy_widget (GncPluginPage *plugin_page)
792792
priv->component_id = 0;
793793
}
794794

795+
priv->tree_view = NULL;
795796
LEAVE("widget destroyed");
796797
}
797798

0 commit comments

Comments
 (0)