未验证 提交 169b22cd 编写于 作者: D Diego Ballesteros Villamizar 提交者: GitHub

Handle glfwGetPrimaryMonitor returning nullptr (#20523)

* Handle glfwGetPrimaryMonitor returning nullptr

[glfwGetPrimaryMonitor](https://www.glfw.org/docs/3.3/group__monitor.html#ga721867d84c6d18d6790d64d2847ca0b1) may return NULL in non-error cases when no monitor is found. This started to happen recently with an update to the linux distribution, see internal b/162545223.

Handling this case avoids a crash and instead assumes a pixel density.
上级 99932282
......@@ -184,6 +184,9 @@ static FlutterDesktopMessage ConvertToDesktopMessage(
// that a screen coordinate is one dp.
static double GetScreenCoordinatesPerInch() {
auto* primary_monitor = glfwGetPrimaryMonitor();
if (primary_monitor == nullptr) {
return kDpPerInch;
}
auto* primary_monitor_mode = glfwGetVideoMode(primary_monitor);
int primary_monitor_width_mm;
glfwGetMonitorPhysicalSize(primary_monitor, &primary_monitor_width_mm,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册