mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-18 01:14:19 +00:00
Resolve Xcode runtime warnings regarding access of NSView/NSWindow properties from a non-main thread
This issue presents when rendering from a thread that is other than the window thread, more easily reproduced when disabling vsync This commit aims to populate the relevant data into backend_data, by way of dispatch_async (ocurring on the main thread). Those particular backend data items are protected by an NSlock There may be more elegant ways to do this Main Thread Checker imgui/backends/imgui_impl_osx.mm:608 -[NSView window] must be used from main thread only imgui/backends/imgui_impl_osx.mm:608 -[NSWindow backingScaleFactor] must be used from main thread only imgui/backends/imgui_impl_osx.mm:609 -[NSView bounds] must be used from main thread only
This commit is contained in:
parent
336d9212fc
commit
6508586fc2
1 changed files with 12 additions and 2 deletions
|
|
@ -625,8 +625,18 @@ void ImGui_ImplOSX_NewFrame(NSView* view)
|
|||
// Setup display size
|
||||
if (view)
|
||||
{
|
||||
const float dpi = (float)[view.window backingScaleFactor];
|
||||
io.DisplaySize = ImVec2((float)view.bounds.size.width, (float)view.bounds.size.height);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[bd->exclusive.lock lock];
|
||||
bd->exclusive.backingScaleFactor = view.window.backingScaleFactor;
|
||||
bd->exclusive.bounds = view.bounds;
|
||||
[bd->exclusive.lock unlock];
|
||||
});
|
||||
|
||||
[bd->exclusive.lock lock];
|
||||
const float dpi = (float) bd->exclusive.backingScaleFactor;
|
||||
io.DisplaySize = ImVec2((float) bd->exclusive.bounds.size.width, bd->exclusive.bounds.size.height);
|
||||
[bd->exclusive.lock unlock];
|
||||
|
||||
io.DisplayFramebufferScale = ImVec2(dpi, dpi);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue