mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-04-11 01:59:58 -04:00
UI: Fix Qt call on UI thread from graphics thread
Calling `devicePixelRatioF` from any thread but the main UI thread triggers thread-safety warnings at runtime on macOS, because Qt uses NSView calls to determine the value. NSView calls are only allowed to be made from the main thread on macOS, so instead the value is stored as a property of the OBSQTDisplay at initialization, to be retrieved from the preview object later. Static functions that do not have access to the preview object have the pixel ratio passed in their call signature.
This commit is contained in:
@@ -319,7 +319,9 @@ OBSBasic::OBSBasic(QWidget *parent)
|
||||
ResizePreview(ovi.base_width, ovi.base_height);
|
||||
|
||||
UpdateContextBarVisibility();
|
||||
dpi = devicePixelRatioF();
|
||||
};
|
||||
dpi = devicePixelRatioF();
|
||||
|
||||
connect(windowHandle(), &QWindow::screenChanged, displayResize);
|
||||
connect(ui->preview, &OBSQTDisplay::DisplayResized, displayResize);
|
||||
@@ -10241,3 +10243,8 @@ void OBSBasic::UpdatePreviewSpacingHelpers()
|
||||
drawSpacingHelpers = config_get_bool(
|
||||
App()->GlobalConfig(), "BasicWindow", "SpacingHelpersEnabled");
|
||||
}
|
||||
|
||||
float OBSBasic::GetDevicePixelRatio()
|
||||
{
|
||||
return dpi;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user