mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-20 11:48:30 -06:00
Bug 797481 - crash on close of unsaved tabs by pressing [X]
My original fix for this was a bit off, the problem wasn't that
the sheet had been freed, it was that the item_edit had so the
ptr to the sheet was garbage. The correct solution is to catch
the item_edit's "destroy" signal and remove the idles.
This commit replaces b5fdcfcb5
.
This commit is contained in:
parent
655e9cd8eb
commit
1d91873ef2
@ -61,7 +61,7 @@ enum
|
|||||||
static GtkBoxClass *gnc_item_edit_parent_class;
|
static GtkBoxClass *gnc_item_edit_parent_class;
|
||||||
|
|
||||||
static GtkToggleButtonClass *gnc_item_edit_tb_parent_class;
|
static GtkToggleButtonClass *gnc_item_edit_tb_parent_class;
|
||||||
|
static void gnc_item_edit_destroying(GtkWidget *this, gpointer data);
|
||||||
static void
|
static void
|
||||||
gnc_item_edit_tb_init (GncItemEditTb *item_edit_tb)
|
gnc_item_edit_tb_init (GncItemEditTb *item_edit_tb)
|
||||||
{
|
{
|
||||||
@ -662,28 +662,6 @@ gnc_item_edit_get_property (GObject *object,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: Idle events calling gnc_item_edit_update can fire after the
|
|
||||||
* GncItemEdit is finalized, but because the GncItemEdit class is
|
|
||||||
* defined by hand instead of with the GType macros there's no way to
|
|
||||||
* run gnc_item_edit_dispose or gnc_item_edit_finalize to null out the
|
|
||||||
* pointers. We resort instead to a weak reference to null out the
|
|
||||||
* sheet when it gets finalized to prevent gnc_item_edit_upate from
|
|
||||||
* accessing the freed sheet.
|
|
||||||
*
|
|
||||||
* https://bugs.gnucash.org/show_bug.cgi?id=797481
|
|
||||||
*
|
|
||||||
* Note that this is still not bulletproof, after all we're still
|
|
||||||
* using the GncItemEdit after it has been freed but without a dispose
|
|
||||||
* function to do this correctly we're a bit stuck.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
sheet_destroyed (gpointer data, GObject *table)
|
|
||||||
{
|
|
||||||
GncItemEdit *item_edit = (GncItemEdit*)data;
|
|
||||||
if (item_edit)
|
|
||||||
item_edit->sheet = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gnc_item_edit_set_property (GObject *object,
|
gnc_item_edit_set_property (GObject *object,
|
||||||
guint param_id,
|
guint param_id,
|
||||||
@ -694,15 +672,7 @@ gnc_item_edit_set_property (GObject *object,
|
|||||||
switch (param_id)
|
switch (param_id)
|
||||||
{
|
{
|
||||||
case PROP_SHEET:
|
case PROP_SHEET:
|
||||||
if (item_edit->sheet)
|
|
||||||
g_object_weak_unref(G_OBJECT(item_edit->sheet),
|
|
||||||
(GWeakNotify)sheet_destroyed,
|
|
||||||
(gpointer)item_edit);
|
|
||||||
item_edit->sheet = GNUCASH_SHEET (g_value_get_object (value));
|
item_edit->sheet = GNUCASH_SHEET (g_value_get_object (value));
|
||||||
if (item_edit->sheet)
|
|
||||||
g_object_weak_ref(G_OBJECT(item_edit->sheet),
|
|
||||||
(GWeakNotify)sheet_destroyed,
|
|
||||||
(gpointer)item_edit);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||||
@ -970,9 +940,18 @@ gnc_item_edit_new (GnucashSheet *sheet)
|
|||||||
|
|
||||||
gtk_box_pack_start (GTK_BOX(item_edit), vb, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX(item_edit), vb, FALSE, FALSE, 0);
|
||||||
gtk_widget_show_all(GTK_WIDGET(item_edit));
|
gtk_widget_show_all(GTK_WIDGET(item_edit));
|
||||||
|
g_signal_connect(G_OBJECT(item_edit), "destroy",
|
||||||
|
G_CALLBACK(gnc_item_edit_destroying), NULL);
|
||||||
return GTK_WIDGET(item_edit);
|
return GTK_WIDGET(item_edit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gnc_item_edit_destroying(GtkWidget *item_edit, gpointer data)
|
||||||
|
{
|
||||||
|
while (g_idle_remove_by_data((gpointer)item_edit))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
check_popup_height_is_true (GtkWidget *widget,
|
check_popup_height_is_true (GtkWidget *widget,
|
||||||
GdkRectangle *allocation,
|
GdkRectangle *allocation,
|
||||||
|
Loading…
Reference in New Issue
Block a user