From 0f89aac9f6f72340c7841964fc199852cb06a562 Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Sun, 19 Feb 2023 17:39:39 +0300 Subject: [PATCH] On Wayland, fix rare crash on DPI change While I don't understand the root cause for this issue, we can dirty fix like that for now. --- CHANGELOG.md | 1 + src/platform_impl/linux/wayland/window/mod.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4667cf47..b169fb0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ And please only add new entries to the top of this list, right below the `# Unre - Implement `HasRawDisplayHandle` for `EventLoop`. - On macOS, set resize increments only for live resizes. +- On Wayland, fix rare crash on DPI change # 0.28.1 diff --git a/src/platform_impl/linux/wayland/window/mod.rs b/src/platform_impl/linux/wayland/window/mod.rs index a775b307..14c31788 100644 --- a/src/platform_impl/linux/wayland/window/mod.rs +++ b/src/platform_impl/linux/wayland/window/mod.rs @@ -128,6 +128,12 @@ impl Window { let surface = event_loop_window_target .env .create_surface_with_scale_callback(move |scale, surface, mut dispatch_data| { + // While I'm not sure how this could happen, we can safely ignore it + // for now as a quickfix. + if !surface.as_ref().is_alive() { + return; + } + let winit_state = dispatch_data.get::().unwrap(); // Get the window that received the event.