Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash after calling DockState::remove_tab. #208

Merged
merged 2 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/dock_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,11 @@ impl<Tab> DockState<Tab> {
&mut self,
(surface_index, node_index, tab_index): (SurfaceIndex, NodeIndex, TabIndex),
) -> Option<Tab> {
self[surface_index].remove_tab((node_index, tab_index))
let removed_tab = self[surface_index].remove_tab((node_index, tab_index));
if !surface_index.is_main() && self[surface_index].is_empty() {
self.remove_surface(surface_index);
}
removed_tab
}

/// Creates two new nodes by splitting a given `parent` node and assigns them as its children. The first (old) node
Expand Down
4 changes: 3 additions & 1 deletion src/dock_state/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,10 @@ impl<Tab> Tree<Tab> {
///
/// # Panics
///
/// If the node at index `node` is not a [`Leaf`](Node::Leaf).
/// - If the tree is empty.
/// - If the node at index `node` is not a [`Leaf`](Node::Leaf).
pub fn remove_leaf(&mut self, node: NodeIndex) {
assert!(!self.is_empty());
assert!(self[node].is_leaf());

let Some(parent) = node.parent() else {
Expand Down
Loading