diff --git a/src/views/mac/SampleAppDelegate.mm b/src/views/mac/SampleAppDelegate.mm index 8211ad9c48..2d45034897 100644 --- a/src/views/mac/SampleAppDelegate.mm +++ b/src/views/mac/SampleAppDelegate.mm @@ -18,6 +18,7 @@ } - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { + [fView freeNativeWind]; application_term(); return NSTerminateNow; } diff --git a/src/views/mac/SkNSView.h b/src/views/mac/SkNSView.h index dfc81ea5bd..9cc29498f6 100644 --- a/src/views/mac/SkNSView.h +++ b/src/views/mac/SkNSView.h @@ -49,4 +49,7 @@ class SkEvent; - (bool)attach:(SkOSWindow::SkBackEndTypes)attachType withMSAASampleCount:(int) sampleCount andGetInfo:(SkOSWindow::AttachmentInfo*) info; - (void)detach; - (void)present; + +- (void)freeNativeWind; + @end diff --git a/src/views/mac/SkNSView.mm b/src/views/mac/SkNSView.mm index 67141679db..e1e03d670b 100644 --- a/src/views/mac/SkNSView.mm +++ b/src/views/mac/SkNSView.mm @@ -118,12 +118,17 @@ SK_COMPILE_ASSERT(SK_SUPPORT_GPU, not_implemented_for_non_gpu_build); } - (void)dealloc { - delete fWind; + [self freeNativeWind]; self.fGLContext = nil; self.fTitle = nil; [super dealloc]; } +- (void)freeNativeWind { + delete fWind; + fWind = nil; +} + //////////////////////////////////////////////////////////////////////////////// - (void)drawSkia { diff --git a/src/views/mac/SkSampleNSView.mm b/src/views/mac/SkSampleNSView.mm index ce5f8aab0a..7c0fc5907b 100644 --- a/src/views/mac/SkSampleNSView.mm +++ b/src/views/mac/SkSampleNSView.mm @@ -18,11 +18,6 @@ return self; } -- (void)dealloc { - delete fWind; - [super dealloc]; -} - - (void)swipeWithEvent:(NSEvent *)event { CGFloat x = [event deltaX]; if (x < 0)