Skip to content

Commit 169b22c

Browse files
Handle glfwGetPrimaryMonitor returning nullptr (flutter#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.
1 parent 9993228 commit 169b22c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

shell/platform/glfw/flutter_glfw.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ static FlutterDesktopMessage ConvertToDesktopMessage(
184184
// that a screen coordinate is one dp.
185185
static double GetScreenCoordinatesPerInch() {
186186
auto* primary_monitor = glfwGetPrimaryMonitor();
187+
if (primary_monitor == nullptr) {
188+
return kDpPerInch;
189+
}
187190
auto* primary_monitor_mode = glfwGetVideoMode(primary_monitor);
188191
int primary_monitor_width_mm;
189192
glfwGetMonitorPhysicalSize(primary_monitor, &primary_monitor_width_mm,

0 commit comments

Comments
 (0)