{"record":{"id":"a514744522d2fd24","repo":"FyroxEngine/Fyrox","slug":"cannot-subtract-window-from-split-tile","errorCode":null,"errorMessage":"Cannot subtract window from split tile","messagePattern":"Cannot subtract window from split tile","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"fyrox-ui/src/dock/tile.rs","lineNumber":147,"sourceCode":"                let current = windows.get(index as usize).copied();\n                windows.retain(|h| h != &window);\n                match windows.len() {\n                    0 => Self::Empty,\n                    1 => Self::Window(windows[0]),\n                    _ => {\n                        let index = if let Some(current) = current {\n                            windows\n                                .iter()\n                                .position(|w| w == &current)\n                                .unwrap_or_default() as u32\n                        } else {\n                            0\n                        };\n                        Self::MultiWindow { index, windows }\n                    }\n                }\n            }\n            _ => panic!(\"Cannot subtract window from split tile\"),\n        }\n    }\n    /// Construct a new tile that makes the given window active.\n    /// If this tile is not a multiwindow or this tile does not contain\n    /// the given window, return self.\n    pub fn with_active(self, window: Handle<Window>) -> Self {\n        match self {\n            Self::MultiWindow { index, windows } => {\n                let index = if let Some(index) = windows.iter().position(|h| h == &window) {\n                    index as u32\n                } else {\n                    index\n                };\n                Self::MultiWindow { index, windows }\n            }\n            _ => self,\n        }\n    }","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/FyroxEngine/Fyrox/blob/76c91aad8eca488ce527b1af707be8b3b24ad72d/fyrox-ui/src/dock/tile.rs#L129-L165","documentation":"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.","triggerScenarios":"Calling Tile::minus_window on a Tile::Split variant, regardless of whether the window handle exists anywhere in the tree.","commonSituations":"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.","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"],"exampleFix":"// before\nroot_tile = root_tile.minus_window(closing_window);\n\n// after\nif matches!(root_tile, Tile::Split { .. }) {\n    root_tile = remove_window_from_children(root_tile, closing_window);\n} else {\n    root_tile = root_tile.minus_window(closing_window);\n}","handlingStrategy":"type-guard","validationCode":"if matches!(tile, Tile::Split { .. }) { descend into children to find the window's tile }","typeGuard":"fn is_leaf_tile(tile: &Tile) -> bool { matches!(tile, Tile::Empty | Tile::Window { .. } | Tile::MultiWindow { .. }) }","tryCatchPattern":"// avoid panic: only call minus_window on Window/MultiWindow variants\nif is_leaf_tile(&tile) { tile.minus_window(w) } else { remove_from_children(tile, w) }","preventionTips":["Search the tile tree for the containing leaf before removing a window","Write one recursive remove-window utility and use it everywhere"],"tags":["panic","ui","dock","invalid-state"],"backgroundTag":"invalid-state-transition","analyzedSha":"76c91aad8eca488ce527b1af707be8b3b24ad72d","analyzedAt":"2026-09-10T16:04:01.633Z","contentChangedAt":"2026-09-10T16:04:01.633Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}