Set up a newer, simpler system for tracking object lifetimes in the Unix backend. Seems to work for now...
This commit is contained in:
parent
b0a56bacb9
commit
160ffed7e2
|
@ -12,12 +12,14 @@ struct singleWidget {
|
||||||
gboolean containerHid;
|
gboolean containerHid;
|
||||||
gboolean userDisabled;
|
gboolean userDisabled;
|
||||||
gboolean containerDisabled;
|
gboolean containerDisabled;
|
||||||
|
gboolean canDestroy;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void singleDestroy(uiControl *c)
|
static void singleDestroy(uiControl *c)
|
||||||
{
|
{
|
||||||
singleWidget *s = (singleWidget *) (c->Internal);
|
singleWidget *s = (singleWidget *) (c->Internal);
|
||||||
|
|
||||||
|
s->canDestroy = TRUE;
|
||||||
gtk_widget_destroy(s->immediate);
|
gtk_widget_destroy(s->immediate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,6 +163,9 @@ static void onDestroy(GtkWidget *widget, gpointer data)
|
||||||
{
|
{
|
||||||
singleWidget *s = (singleWidget *) data;
|
singleWidget *s = (singleWidget *) data;
|
||||||
|
|
||||||
|
if (!s->canDestroy)
|
||||||
|
// TODO switch to complain()
|
||||||
|
g_error("trying to destroy control with singleWidget at %p before uiControlDestroy()", s);
|
||||||
uiFree(s);
|
uiFree(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ struct uipParent {
|
||||||
intmax_t marginTop;
|
intmax_t marginTop;
|
||||||
intmax_t marginRight;
|
intmax_t marginRight;
|
||||||
intmax_t marginBottom;
|
intmax_t marginBottom;
|
||||||
|
gboolean canDestroy;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct uipParentClass {
|
struct uipParentClass {
|
||||||
|
@ -41,19 +42,24 @@ static void uipParent_dispose(GObject *obj)
|
||||||
{
|
{
|
||||||
uipParent *p = uipParent(obj);
|
uipParent *p = uipParent(obj);
|
||||||
|
|
||||||
|
// don't free mainControl here; that should have been done by uiParentDestroy()
|
||||||
|
if (!p->canDestroy)
|
||||||
|
// TODO switch to complain()
|
||||||
|
g_error("attempt to dispose uiParent with uipParent at %p before uiParentDestroy()", p);
|
||||||
if (p->children != NULL) {
|
if (p->children != NULL) {
|
||||||
g_ptr_array_unref(p->children);
|
g_ptr_array_unref(p->children);
|
||||||
p->children = NULL;
|
p->children = NULL;
|
||||||
}
|
}
|
||||||
if (p->mainControl != NULL) {
|
|
||||||
uiControlDestroy(p->mainControl);
|
|
||||||
p->mainControl = NULL;
|
|
||||||
}
|
|
||||||
G_OBJECT_CLASS(uipParent_parent_class)->dispose(obj);
|
G_OBJECT_CLASS(uipParent_parent_class)->dispose(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void uipParent_finalize(GObject *obj)
|
static void uipParent_finalize(GObject *obj)
|
||||||
{
|
{
|
||||||
|
uipParent *p = uipParent(obj);
|
||||||
|
|
||||||
|
if (!p->canDestroy)
|
||||||
|
// TODO switch to complain()
|
||||||
|
g_error("attempt to finalize uiParent with uipParent at %p before uiParentDestroy()", p);
|
||||||
G_OBJECT_CLASS(uipParent_parent_class)->finalize(obj);
|
G_OBJECT_CLASS(uipParent_parent_class)->finalize(obj);
|
||||||
if (options.debugLogAllocations)
|
if (options.debugLogAllocations)
|
||||||
fprintf(stderr, "%p free\n", obj);
|
fprintf(stderr, "%p free\n", obj);
|
||||||
|
@ -137,6 +143,11 @@ static void parentDestroy(uiParent *pp)
|
||||||
{
|
{
|
||||||
uipParent *p = uipParent(pp->Internal);
|
uipParent *p = uipParent(pp->Internal);
|
||||||
|
|
||||||
|
p->canDestroy = TRUE;
|
||||||
|
if (p->mainControl != NULL) {
|
||||||
|
uiControlDestroy(p->mainControl);
|
||||||
|
p->mainControl = NULL;
|
||||||
|
}
|
||||||
gtk_widget_destroy(GTK_WIDGET(p));
|
gtk_widget_destroy(GTK_WIDGET(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue