diff --git a/src/native/macosx/OSXWindowFrameView.m b/src/native/macosx/OSXWindowFrameView.m index b5dd20d..5b3a992 100644 --- a/src/native/macosx/OSXWindowFrameView.m +++ b/src/native/macosx/OSXWindowFrameView.m @@ -24,20 +24,20 @@ - (void)drawRect:(NSRect)rect { - CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort]; + CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort]; - CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB(); - CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, draw_buffer, width * height * 4, NULL); + CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB(); + CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, draw_buffer, width * height * 4, NULL); - CGImageRef img = CGImageCreate(width, height, 8, 32, width * 4, space, kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, - provider, NULL, false, kCGRenderingIntentDefault); + CGImageRef img = CGImageCreate(width, height, 8, 32, width * 4, space, kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, + provider, NULL, false, kCGRenderingIntentDefault); - CGColorSpaceRelease(space); - CGDataProviderRelease(provider); + CGColorSpaceRelease(space); + CGDataProviderRelease(provider); - CGContextDrawImage(context, CGRectMake(0, 0, width * scale, height * scale), img); + CGContextDrawImage(context, CGRectMake(0, 0, width * scale, height * scale), img); - CGImageRelease(img); + CGImageRelease(img); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -109,27 +109,30 @@ - (void)viewDidMoveToWindow { - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(windowResized:) name:NSWindowDidResizeNotification - object:[self window]]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(windowResized:) name:NSWindowDidResizeNotification + object:[self window]]; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - (void)dealloc { - [[NSNotificationCenter defaultCenter] removeObserver:self]; - [super dealloc]; + [[NSNotificationCenter defaultCenter] removeObserver:self]; + [super dealloc]; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - (void)windowResized:(NSNotification *)notification; { - NSSize size = [self bounds].size; + NSSize size = [self bounds].size; OSXWindow* window = (OSXWindow*)[self window]; - window->shared_data->width = (int)(size.width); - window->shared_data->height = (int)(size.height); + + if (window->shared_data) { + window->shared_data->width = (int)(size.width); + window->shared_data->height = (int)(size.height); + } } @end