Переглянути джерело

libobs-opengl: Fix projector crash with external macOS displays

When an external display is disconnected with a fullscreen projector
attached to it, Qt will trigger a resize of the window twice, which
makes the renderer queue 2 resize event blocks.

At the time when those blocks are run, Qt's window destructor will have
reset all pointers, and the block directly accesses pointers within
structures identified by pointers, which are invalid by that point.

This commit makes a block return early if the associated window has
been destroyed already and also explicitly checks for valid pointers
after.
PatTheMav 2 роки тому
батько
коміт
27ba216271
1 змінених файлів з 4 додано та 0 видалено
  1. 4 0
      libobs-opengl/gl-cocoa.m

+ 4 - 0
libobs-opengl/gl-cocoa.m

@@ -228,6 +228,10 @@ void gl_update(gs_device_t *device)
 	NSOpenGLContext *parent = device->plat->context;
 	NSOpenGLContext *context = swap->wi->context;
 	dispatch_async(dispatch_get_main_queue(), ^() {
+		if (!swap || !swap->wi) {
+			return;
+		}
+
 		CGLContextObj parent_obj = [parent CGLContextObj];
 		CGLLockContext(parent_obj);