From 0c2faae48bae7e0147740b9ac47c1aafe9c2e9c3 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 1 Feb 2020 17:11:56 +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 --- source/platform/posix/cocoa/i_video.mm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source/platform/posix/cocoa/i_video.mm b/source/platform/posix/cocoa/i_video.mm index 0ce82e3d0..1cc73a343 100644 --- a/source/platform/posix/cocoa/i_video.mm +++ b/source/platform/posix/cocoa/i_video.mm @@ -186,8 +186,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