More destruction rules following code.

This commit is contained in:
Pietro Gagliardi 2015-04-19 22:59:06 -04:00
parent 0af03e5410
commit 21a29a5468
5 changed files with 9 additions and 1 deletions

View File

@ -22,7 +22,7 @@
- settle onDestroy/destroy naming
- clean up Windows lifetiming code
- forbid free(NULL) to check for bugs
- figure out how to do the parent on destroy check for uiStack
- figure out how to do the parent on destroy check for children of a uiStack without a parent in and of itself
ultimately:
- make everything vtable-based

View File

@ -27,6 +27,8 @@ uiLogObjCClassAllocations
- (void)uipDestroyMainControl
{
if (self->mainControl != NULL) {
// we have to do this before we can destroy controls
uiControlSetParent(p->mainControl, NULL);
uiControlDestroy(self->mainControl);
self->mainControl = NULL;
}

View File

@ -33,6 +33,8 @@ static void stackDestroy(uiControl *c)
stack *s = (stack *) c;
uintmax_t i;
if (s->parent != NULL)
complain("attempt to destroy a uiControl at %p while it still has a parent %p", c, s->parent);
for (i = 0; i < s->len; i++)
uiControlDestroy(s->controls[i].c);
uiFree(s->controls);

View File

@ -146,6 +146,8 @@ static void parentDestroy(uiParent *pp)
// first, destroy the main control
if (p->mainControl != NULL) {
// we have to do this before we can destroy controls
uiControlSetParent(p->mainControl, NULL);
uiControlDestroy(p->mainControl);
p->mainControl = NULL;
}

View File

@ -235,6 +235,8 @@ static void parentDestroy(uiParent *pp)
// first destroy the main control, if any
if (p->mainControl != NULL) {
// we have to do this before we can destroy controls
uiControlSetParent(p->mainControl, NULL);
uiControlDestroy(p->mainControl);
p->mainControl = NULL;
}