diff --git a/panda/src/cocoadisplay/cocoaGraphicsBuffer.mm b/panda/src/cocoadisplay/cocoaGraphicsBuffer.mm index ea6fb61e4e..07f44b6c94 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsBuffer.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsBuffer.mm @@ -105,6 +105,12 @@ open_buffer() { } } + if (cocoagsg->_context == nil) { + // Could not obtain a proper context. + _gsg.clear(); + return false; + } + FrameBufferProperties desired_props(_fb_properties); // Lock the context, so we can safely operate on it. diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm index 35f71f6614..df12a69985 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm @@ -362,6 +362,13 @@ open_window() { } } + if (cocoagsg->_context == nil) { + // Could not obtain a proper context. + _gsg.clear(); + close_window(); + return false; + } + // Fill in the blanks. if (!_properties.has_origin()) { _properties.set_origin(-2, -2);