Added code to check that a control is not destroyed while it has a parent. This isn't enough for uiStack, though...

This commit is contained in:
Pietro Gagliardi 2015-04-19 22:52:51 -04:00
parent 91522894c1
commit 24469a6e7b
3 changed files with 6 additions and 4 deletions

View File

@ -20,12 +20,10 @@ static void singleDestroy(uiControl *c)
{
singleView *s = (singleView *) (c->Internal);
if (s->parent != NULL)
complain("attempt to destroy a uiControl at %p while it still has a parent %p", c, s->parent);
[s->immediate retain]; // to keep alive when removing
(*(s->onDestroy))(s->onDestroyData);
if (s->parent != NULL) {
[s->immediate removeFromSuperview];
s->parent = NULL;
}
[destroyedControlsView addSubview:s->immediate];
[s->immediate release];
}

View File

@ -21,6 +21,8 @@ static void singleDestroy(uiControl *c)
{
singleWidget *s = (singleWidget *) (c->Internal);
if (s->parent != NULL)
complain("attempt to destroy a uiControl at %p while it still has a parent %p", c, s->parent);
// first call the widget's own destruction code
(*(s->onDestroy))(s->onDestroyData);
// then mark that we are ready to be destroyed

View File

@ -20,6 +20,8 @@ static void singleDestroy(uiControl *c)
{
singleHWND *s = (singleHWND *) (c->Internal);
if (s->parent != NULL)
complain("attempt to destroy a uiControl at %p while it still has a parent %p", c, s->parent);
SendMessageW(s->hwnd, msgCanDestroyNow, 0, 0);
(*(s->onDestroy))(s->onDestroyData);
if (DestroyWindow(s->hwnd) == 0)