Browse Source

cocoadisplay: don't crash if window/buffer fails to open

rdb 7 years ago
parent
commit
57602d750f

+ 6 - 0
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.

+ 7 - 0
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);