mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-28 15:53:55 -04:00
cocoadisplay: Fix crash with threading-model on newer macOS versions
Updates the context on the main thread instead of the draw thread now. If render_frame happens to run while the context needs updating, it will skip the frame. Fixes #1286
This commit is contained in:
parent
4c6df54d6f
commit
4cf8187df7
@ -207,8 +207,13 @@ begin_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
|
|
||||||
// Update the context if necessary, to make it reallocate buffers etc.
|
// Update the context if necessary, to make it reallocate buffers etc.
|
||||||
if (_context_needs_update) {
|
if (_context_needs_update) {
|
||||||
[cocoagsg->_context update];
|
if ([NSThread isMainThread]) {
|
||||||
_context_needs_update = false;
|
[cocoagsg->_context update];
|
||||||
|
_context_needs_update = false;
|
||||||
|
} else {
|
||||||
|
cocoagsg->unlock_context();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lock the view for drawing.
|
// Lock the view for drawing.
|
||||||
@ -349,6 +354,18 @@ process_events() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[pool release];
|
[pool release];
|
||||||
|
|
||||||
|
if (_context_needs_update && _gsg != nullptr) {
|
||||||
|
CocoaGraphicsStateGuardian *cocoagsg;
|
||||||
|
DCAST_INTO_V(cocoagsg, _gsg);
|
||||||
|
|
||||||
|
if (cocoagsg != nullptr && cocoagsg->_context != nil) {
|
||||||
|
cocoagsg->lock_context();
|
||||||
|
_context_needs_update = false;
|
||||||
|
[cocoagsg->_context update];
|
||||||
|
cocoagsg->unlock_context();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1194,6 +1211,18 @@ set_properties_now(WindowProperties &properties) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_context_needs_update && _gsg != nullptr) {
|
||||||
|
CocoaGraphicsStateGuardian *cocoagsg;
|
||||||
|
DCAST_INTO_V(cocoagsg, _gsg);
|
||||||
|
|
||||||
|
if (cocoagsg != nullptr && cocoagsg->_context != nil) {
|
||||||
|
cocoagsg->lock_context();
|
||||||
|
_context_needs_update = false;
|
||||||
|
[cocoagsg->_context update];
|
||||||
|
cocoagsg->unlock_context();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user