summaryrefslogtreecommitdiff
path: root/new/newcontrol_darwin.m
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2015-04-10 23:22:46 -0400
committerPietro Gagliardi <[email protected]>2015-04-10 23:22:46 -0400
commitc610c60ea6266fe68c2f06627c0bdbedaa5731bb (patch)
tree48d7027b0e11a39cdb8fe2f07fb4e9bf075530ac /new/newcontrol_darwin.m
parent47c89f6aefcae52301d621634701e7b676487e50 (diff)
Started to implement proper destruction logic for Mac OS X controls.
Diffstat (limited to 'new/newcontrol_darwin.m')
-rw-r--r--new/newcontrol_darwin.m9
1 files changed, 6 insertions, 3 deletions
diff --git a/new/newcontrol_darwin.m b/new/newcontrol_darwin.m
index f53ef58..1fff8a8 100644
--- a/new/newcontrol_darwin.m
+++ b/new/newcontrol_darwin.m
@@ -10,12 +10,11 @@ struct singleView {
uintptr_t parent;
};
-// TODO this will need to change if we want to provide removal
static void singleDestroy(uiControl *c)
{
singleView *s = (singleView *) (c->internal);
- [s->view removeFromSuperview];
+ [deletedControlsView addSubview:s->immediate];
}
static uintptr_t singleHandle(uiControl *c)
@@ -99,6 +98,9 @@ uiControl *uiDarwinNewControl(Class class, BOOL inScrollView, BOOL scrollViewHas
s->immediate = (NSView *) (s->scrollView);
}
+ // and keep a reference to s->immediate for when we remove the control from its parent
+ [s->immediate retain];
+
c = uiNew(uiControl);
c->internal = s;
c->destroy = singleDestroy;
@@ -115,7 +117,8 @@ BOOL uiDarwinControlFreeWhenAppropriate(uiControl *c, NSView *newSuperview)
{
singleView *s = (singleView *) (c->internal);
- if (newSuperview == nil) {
+ if (newSuperview == deletedControlsView) {
+ [s->immediate release]; // we don't need the reference anymore
uiFree(s);
uiFree(c);
return YES;