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

DockState<Tab>::remove_tab may cause the whole program panic when the tab is the last tab of a window. #206

Closed
sakura6264 opened this issue Dec 8, 2023 · 3 comments · Fixed by #208
Labels
bug Something isn't working

Comments

@sakura6264
Copy link

Describe the bug
when use remove_tab function to remove the last tab from a window, it could not close the window like clicking on the tab.
And in the next time I call egui_dock::DockArea::show_inside, the program panic.

To Reproduce
Steps to reproduce the behavior:

match self.tree.find_tab(&tab) {
                        Some(index) => {
                            self.tree.remove_tab(index);
                        }
                        None => {
                            self.tree.add_window(vec![tab]);
                        }
                    }

Is there any way to close the tab from rust code just like what it happens when I click the close button?

@sakura6264 sakura6264 added the bug Something isn't working label Dec 8, 2023
@Adanos020
Copy link
Owner

Is there any way to close the tab from rust code just like what it happens when I click the close button?

Yes, you can override TabViewer::force_close.

@sakura6264
Copy link
Author

This function works. Thanks very much.

@Adanos020 Adanos020 added duplicate This issue or pull request already exists and removed duplicate This issue or pull request already exists labels Dec 10, 2023
@Adanos020
Copy link
Owner

Now to actually fix the issue: looks like tabs in windows aren't correctly deleted with DockState::remove_tab, leaving a Surface without a leaf node. We need to also delete the surface when that happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants