{"record":{"id":"c25b29e47ff0bdd2","repo":"FyroxEngine/Fyrox","slug":"cannot-add-window-to-split-tile","errorCode":null,"errorMessage":"Cannot add window to split tile","messagePattern":"Cannot add window to split tile","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"fyrox-ui/src/dock/tile.rs","lineNumber":112,"sourceCode":"        }\n    }\n    /// Construct a new tile that adds the given window to this tile.\n    /// This tile must be either empty, a window, or a multiwindow, or else panic.\n    pub fn plus_window(self, window: Handle<Window>) -> Self {\n        match self {\n            Self::Empty => Self::Window(window),\n            Self::Window(handle) => Self::MultiWindow {\n                index: 0,\n                windows: vec![window, handle],\n            },\n            Self::MultiWindow { mut windows, .. } => {\n                windows.push(window);\n                Self::MultiWindow {\n                    index: windows.len() as u32 - 1,\n                    windows,\n                }\n            }\n            _ => panic!(\"Cannot add window to split tile\"),\n        }\n    }\n    /// Construct a new tile that removes the given window from this tile.\n    /// This tile must be either empty, a window, or a multiwindow, or else panic.\n    /// If the window does not exist in this tile, then return self.\n    pub fn minus_window(self, window: Handle<Window>) -> Self {\n        match self {\n            Self::Empty => Self::Empty,\n            Self::Window(handle) => {\n                if window == handle {\n                    Self::Empty\n                } else {\n                    self\n                }\n            }\n            Self::MultiWindow { index, mut windows } => {\n                let current = windows.get(index as usize).copied();\n                windows.retain(|h| h != &window);","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/FyroxEngine/Fyrox/blob/76c91aad8eca488ce527b1af707be8b3b24ad72d/fyrox-ui/src/dock/tile.rs#L94-L130","documentation":"Tile::plus_window can only add a window to a tile that is Empty, a single Window, or MultiWindow. If the tile is a Split (contains child tiles), there is no defined place to put the window, so the library panics deliberately as an internal state violation.","triggerScenarios":"Calling Tile::plus_window on a tile constructed via split_left_right/split_top_bottom (Tile::Split variant).","commonSituations":"Dock layout manipulation code that walks a tile tree adding windows without checking whether the tile is a split container; saving/restoring custom dock layouts programmatically.","solutions":["Match on the tile and only call plus_window for Empty/Window/MultiWindow variants","If the tile is a Split, add the window to one of its child tiles instead","Track tile kind in your own layout state before mutating it"],"exampleFix":"// before\ntile = tile.plus_window(window_handle);\n\n// after\ntile = match tile {\n    Tile::Split { .. } => tile.with_content(...), // or add to a child tile\n    _ => tile.plus_window(window_handle),\n};","handlingStrategy":"type-guard","validationCode":"if matches!(tile, Tile::Split { .. }) { panic-guard: handle split case separately }","typeGuard":"fn can_add_window(tile: &Tile) -> bool { !matches!(tile, Tile::Split { .. }) }","tryCatchPattern":"// Rust panics are not catchable here without catch_unwind; guard by matching variants before the call\nmatch tile { Tile::Split { .. } => /* route to child */, _ => tile.plus_window(w) }","preventionTips":["Always match on Tile variants before plus_window/minus_window","Encapsulate dock mutations in a helper that handles Split by recursion"],"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"}