From 442f953d67ef39ff5c9df00f719c0f3cc44c2fe5 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 7 Jan 2020 14:37:25 +0200 Subject: [PATCH] - fixed invalid context warnings with Cocoa backend A bunch of 'CGContext<...>: invalid context 0x0' messages were printed to console during OpenGL view creation and resizing --- src/posix/cocoa/i_video.mm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index d6d93ce489..90f41f8ee5 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -187,8 +187,15 @@ namespace - (void)drawRect:(NSRect)dirtyRect { - [NSColor.blackColor setFill]; - NSRectFill(dirtyRect); + if ([NSGraphicsContext currentContext]) + { + [NSColor.blackColor setFill]; + NSRectFill(dirtyRect); + } + else if (self.layer != nil) + { + self.layer.backgroundColor = CGColorGetConstantColor(kCGColorBlack); + } } - (void)resetCursorRects