Skip to content

GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.

feat: prevent error on close if window is no longer valid

Lars Berger58a604743009
diff --git a/packages/wm/src/app_command.rs b/packages/wm/src/app_command.rs
index f14adc54..aacba1ea 100644
--- a/packages/wm/src/app_command.rs
+++ b/packages/wm/src/app_command.rs
@@ -3,7 +3,7 @@ use std::{iter, path::PathBuf};
use anyhow::{bail, Context};
use clap::{error::KindFormatter, Args, Parser, ValueEnum};
use serde::{Deserialize, Deserializer, Serialize};
-use tracing::Level;
+use tracing::{warn, Level};
use uuid::Uuid;
use crate::{
@@ -278,7 +278,14 @@ impl InvokeCommand {
}
InvokeCommand::Close => {
match subject_container.as_window_container() {
- Ok(window) => window.native().close(),
+ Ok(window) => {
+ // Window handle might no longer be valid here.
+ if let Err(err) = window.native().close() {
+ warn!("Failed to close window: {:?}", err);
+ }
+
+ Ok(())
+ }
_ => Ok(()),
}
}