From 90c0d46f04f036f021a3cbea962a00a2a2c033ce Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Wed, 24 Nov 2021 21:13:38 +0100 Subject: [PATCH] Fix a panic with dolphin-emu-nogui That app pops up a window which has neither app_id nor name which I assumed all windows have. Now check for pid and shell to determine a con't type as window. --- Cargo.lock | 4 ++-- src/tree.rs | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 086d710..0971705 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -150,9 +150,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.107" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbe5e23404da5b4f555ef85ebed98fb4083e55a00c317800bc2a50ede9f3d219" +checksum = "8521a1b57e76b1ec69af7599e75e38e7b7fad6610f037db8c79b127201b5d119" [[package]] name = "memchr" diff --git a/src/tree.rs b/src/tree.rs index 8f7a7f6..6ca7be4 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -93,19 +93,24 @@ impl NodeMethods for s::Node { if self.node_type == s::NodeType::Con && self.name.is_none() && self.app_id.is_none() + && self.pid.is_none() + && self.shell.is_none() && self.window_properties.is_none() && self.layout != s::NodeLayout::None { Type::Container } else if (self.node_type == s::NodeType::Con || self.node_type == s::NodeType::FloatingCon) - && self.name.is_some() + // Apparently there can be windows without app_id, name, + // and window_properties.class, e.g., dolphin-emu-nogui. + && self.pid.is_some() + && self.shell.is_some() { Type::Window } else { panic!( - "Don't know type of node with id {} and node_type {:?}", - self.id, self.node_type + "Don't know type of node with id {} and node_type {:?}\n{:?}", + self.id, self.node_type, self ) } }