Fixed bin destruction on Mac OS X.

This commit is contained in:
Pietro Gagliardi 2015-05-06 01:38:32 -04:00
parent a15bb12ad1
commit 2c7bccb3a8
2 changed files with 6 additions and 2 deletions

View File

@ -19,6 +19,7 @@ static void destroy(void *data)
while ([t->tabview numberOfTabViewItems] != 0)
[t->tabview removeTabViewItem:[t->tabview tabViewItemAtIndex:0]];
// then destroy all the bins, destroying children in the process
// the above loop serves the purpose of binSetParent()
[t->pages enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
NSValue *v = (NSValue *) obj;
uiContainer *p;
@ -119,6 +120,7 @@ static void tabDeletePage(uiTab *tt, uintmax_t n)
binSetMainControl(p, NULL);
// remove the bin from the tab view
// this serves the purpose of binSetParent()
i = [t->tabview tabViewItemAtIndex:n];
[t->tabview removeTabViewItem:i];

View File

@ -59,8 +59,10 @@ static void windowDestroy(uiControl *c)
// first hide ourselves
[w->window orderOut:w->window];
// now destroy the bin
// the bin has no parent, so we can just call uiControlDestroy()
// we also don't have to worry about the NSWindow's reference to the content view; that'll be released too
// we need to remove the bin from its parent; this is equivalent to calling binSetParent()
// we do this by changing the content view to a dummy view
// the window will release its reference on the bin now, then it will release its reference on the dummy view when the window itself is finally released
[w->window setContentView:[[NSView alloc] initWithFrame:NSZeroRect]];
uiControlDestroy(uiControl(w->bin));
// now destroy the delegate
[w->window setDelegate:nil];