summaryrefslogtreecommitdiff
path: root/new/window_darwin.m
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2015-04-08 15:53:50 -0400
committerPietro Gagliardi <[email protected]>2015-04-08 15:53:50 -0400
commitbb229f9dc110fbc1293be02c71ca4b37b038081e (patch)
tree2c02fee4340f9af429810c6e801df33ae249b270 /new/window_darwin.m
parent25b33c2afd8aa772002f136c2f3bd9d56e22a0ca (diff)
Built up a better system for handling data cleanup on Mac OS X; thanks to http://stackoverflow.com/questions/29522715/is-there-a-reliable-way-to-destroy-private-data-structures-when-a-standard-nsvie.
Diffstat (limited to 'new/window_darwin.m')
-rw-r--r--new/window_darwin.m6
1 files changed, 5 insertions, 1 deletions
diff --git a/new/window_darwin.m b/new/window_darwin.m
index 4733530..465923c 100644
--- a/new/window_darwin.m
+++ b/new/window_darwin.m
@@ -4,7 +4,9 @@
// TODO
// - showing on size
+// TODO clean this up
@interface uiWindowDelegate : NSObject <NSWindowDelegate>
+@property (assign) NSWindow *win;
@property uiWindow *w;
@property int (*onClosing)(uiWindow *, void *);
@property void *onClosingData;
@@ -12,7 +14,7 @@
@implementation uiWindowDelegate
-uiLogObjCClassAllocations()
+uiLogObjCClassAllocations
- (BOOL)windowShouldClose:(id)win
{
@@ -25,6 +27,7 @@ uiLogObjCClassAllocations()
// after this method returns we assume the window will be released (see below), so we can go too
- (void)windowWillClose:(NSNotification *)note
{
+ [self.win setDelegate:nil]; // see http://stackoverflow.com/a/29523141/3408572
uiFree(self.w);
[self release];
}
@@ -63,6 +66,7 @@ uiWindow *uiNewWindow(char *title, int width, int height)
[w->w setContentView:((NSView *) w->container)];
w->d = [uiWindowDelegate new];
+ w->d.win = w->w;
w->d.w = w;
w->d.onClosing = defaultOnClosing;
[w->w setDelegate:w->d];