Attempted to fix uiTab resource freeing on OS X. Seems to work for removing tabs, not sure about deleting controls because of other crashes.
This commit is contained in:
parent
64dd45343d
commit
1034978a2e
11
darwin/tab.m
11
darwin/tab.m
|
@ -12,14 +12,18 @@ static void destroy(void *data)
|
||||||
{
|
{
|
||||||
struct tab *t = (struct tab *) data;
|
struct tab *t = (struct tab *) data;
|
||||||
|
|
||||||
|
// first destroy all tab pages so we can destroy all the bins
|
||||||
|
while ([t->tabview numberOfTabViewItems] != 0)
|
||||||
|
[t->tabview removeTabViewItem:[t->tabview tabViewItemAtIndex:0]];
|
||||||
|
// then destroy all the bins, destroying children in the process
|
||||||
[t->pages enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
|
[t->pages enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
|
||||||
NSValue *v = (NSValue *) obj;
|
NSValue *v = (NSValue *) obj;
|
||||||
uiContainer *p;
|
uiContainer *p;
|
||||||
|
|
||||||
// TODO this is definitely wrong but
|
|
||||||
p = (uiContainer *) [v pointerValue];
|
p = (uiContainer *) [v pointerValue];
|
||||||
uiControlDestroy(uiControl(p));
|
uiControlDestroy(uiControl(p));
|
||||||
}];
|
}];
|
||||||
|
// and finally destroy ourselves
|
||||||
[t->pages release];
|
[t->pages release];
|
||||||
[t->margined release];
|
[t->margined release];
|
||||||
uiFree(t);
|
uiFree(t);
|
||||||
|
@ -69,9 +73,12 @@ static void tabDeletePage(uiTab *tt, uintmax_t n)
|
||||||
// make sure the children of the tab aren't destroyed
|
// make sure the children of the tab aren't destroyed
|
||||||
binSetMainControl(p, NULL);
|
binSetMainControl(p, NULL);
|
||||||
|
|
||||||
// TODO negotiate lifetimes better
|
// remove the bin from the tab view
|
||||||
i = [t->tabview tabViewItemAtIndex:n];
|
i = [t->tabview tabViewItemAtIndex:n];
|
||||||
[t->tabview removeTabViewItem:i];
|
[t->tabview removeTabViewItem:i];
|
||||||
|
|
||||||
|
// then destroy the bin
|
||||||
|
uiControlDestroy(uiControl(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
static uintmax_t tabNumPages(uiTab *tt)
|
static uintmax_t tabNumPages(uiTab *tt)
|
||||||
|
|
Loading…
Reference in New Issue