diff --git a/darwin/newcontrol.m b/darwin/newcontrol.m index 029cab58..71146ac2 100644 --- a/darwin/newcontrol.m +++ b/darwin/newcontrol.m @@ -19,9 +19,10 @@ static void singleDestroy(uiControl *c) if (s->parent != NULL) complain("attempt to destroy a uiControl at %p while it still has a parent", c); - [s->immediate retain]; // to keep alive when removing (*(s->onDestroy))(s->onDestroyData); + // release the reference we took on creation to destroy the widget [s->immediate release]; + uiFree(s); } static uintptr_t singleHandle(uiControl *c) @@ -31,7 +32,6 @@ static uintptr_t singleHandle(uiControl *c) return (uintptr_t) (s->view); } -// TODO update refcounting here and in the GTK+ port static void singleSetParent(uiControl *c, uiContainer *parent) { singleView *s = (singleView *) (c->Internal); diff --git a/unix/newcontrol.c b/unix/newcontrol.c index 82497be3..89e2930d 100644 --- a/unix/newcontrol.c +++ b/unix/newcontrol.c @@ -150,15 +150,7 @@ void uiUnixNewControl(uiControl *c, GType type, gboolean inScrolledWindow, gbool } // we need to keep an extra reference on the immediate widget - // this is so uiControlDestroy() can work regardless of when it is called and who calls it - // without this: - // - end user call works (only one ref) - // - call in uiContainer destructor fails (uiContainer ref freed) - // with this: - // - end user call works (shoudn't be in any container) - // - call in uiContainer works (both refs freed) - // this also ensures singleRemoveParent() works properly - // TODO double-check this for new parenting rules + // this is so we can reparent the control freely g_object_ref_sink(s->immediate); s->onDestroy = onDestroy;