FyroxEngine/Fyrox · error
Cannot subtract window from split tile
Error message
Cannot subtract window from split tile
What it means
Tile::minus_window can only remove a window from a tile that is a Window or MultiWindow. If the tile is a Split, it holds no direct windows, so removal is undefined and the library panics. The docs state the tile must be empty, a window, or a multiwindow.
Solutions
- Match the tile and only call minus_window on Window/MultiWindow variants
- For Split tiles, recurse into children to find the tile containing the window
- Use TileContentIterator or find the window's containing tile before removal
Example fix
// before
root_tile = root_tile.minus_window(closing_window);
// after
if matches!(root_tile, Tile::Split { .. }) {
root_tile = remove_window_from_children(root_tile, closing_window);
} else {
root_tile = root_tile.minus_window(closing_window);
} Defensive patterns
Strategy: type-guard
Validate before calling
if matches!(tile, Tile::Split { .. }) { descend into children to find the window's tile } Type guard
fn is_leaf_tile(tile: &Tile) -> bool { matches!(tile, Tile::Empty | Tile::Window { .. } | Tile::MultiWindow { .. }) } Try / catch
// avoid panic: only call minus_window on Window/MultiWindow variants
if is_leaf_tile(&tile) { tile.minus_window(w) } else { remove_from_children(tile, w) } Prevention
- Search the tile tree for the containing leaf before removing a window
- Write one recursive remove-window utility and use it everywhere
When it happens
Trigger: Calling Tile::minus_window on a Tile::Split variant, regardless of whether the window handle exists anywhere in the tree.
Common situations: Closing docked windows by traversing the tile tree from the root without descending into split children first; generic tile-mutation utilities that assume a leaf tile.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Cannot add window to split tile
- Invalid texture kind.
- Animation pool must be empty on load!
- Cast to failed!
- An object at index must be returned to a pool it was taken…
AI-assisted analysis of FyroxEngine/Fyrox@76c91aad8e (2026-09-10).
Data as JSON: /api/errors/a514744522d2fd24.
Report an issue: GitHub.
Appendix: source
Thrown at fyrox-ui/src/dock/tile.rs:147
let current = windows.get(index as usize).copied();
windows.retain(|h| h != &window);
match windows.len() {
0 => Self::Empty,
1 => Self::Window(windows[0]),
_ => {
let index = if let Some(current) = current {
windows
.iter()
.position(|w| w == ¤t)
.unwrap_or_default() as u32
} else {
0
};
Self::MultiWindow { index, windows }
}
}
}
_ => panic!("Cannot subtract window from split tile"),
}
}
/// Construct a new tile that makes the given window active.
/// If this tile is not a multiwindow or this tile does not contain
/// the given window, return self.
pub fn with_active(self, window: Handle<Window>) -> Self {
match self {
Self::MultiWindow { index, windows } => {
let index = if let Some(index) = windows.iter().position(|h| h == &window) {
index as u32
} else {
index
};
Self::MultiWindow { index, windows }
}
_ => self,
}
}View on GitHub (pinned to 76c91aad8e)