Made refcounting for new control on GTK+ and OS X consistent.
This commit is contained in:
parent
40dee5a693
commit
185d9cf122
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue