Skip to content

Commit

Permalink
When the window will close, set appkit host view's layout manager to …
Browse files Browse the repository at this point in the history
…nil.
  • Loading branch information
luosheng committed Oct 23, 2012
1 parent 470dffd commit ce028dc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/UIKit/TUINSView.m
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ - (CALayer *)focusRingLayerForView:(NSView *)view;
*/
- (void)setUp;

- (void)windowWillClose:(NSNotification *)notification;
- (void)windowDidResignKey:(NSNotification *)notification;
- (void)windowDidBecomeKey:(NSNotification *)notification;
- (void)screenProfileOrBackingPropertiesDidChange:(NSNotification *)notification;
Expand Down Expand Up @@ -651,13 +652,20 @@ - (void)setUp {
// set up masking on the AppKit host view, and make ourselves the layout
// manager, so that we'll know when new sublayers are added
self.appKitHostView.layer.layoutManager = self;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowWillClose:) name:NSWindowWillCloseNotification object:self.window];

#if ENABLE_NSVIEW_CLIPPING
self.appKitHostView.layer.mask = self.maskLayer;
[self recalculateNSViewClipping];
#endif
}

- (void)windowWillClose:(NSNotification *)notification {
// since the layer retains the layoutManger, we need to set it to nil to
// make sure TUINSView will be deallocated
self.appKitHostView.layer.layoutManager = nil;
}

- (void)didAddSubview:(NSView *)view {
NSAssert(view == self || view == self.appKitHostView, @"Subviews should not be added to TUINSView %@: %@", self, view);
[super didAddSubview:view];
Expand Down

0 comments on commit ce028dc

Please sign in to comment.