-
Notifications
You must be signed in to change notification settings - Fork 76
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
restore root node, when all tabs are removed #231
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a good solution to the problem, as it causes another bug: if all tabs get removed from the main surface and there are any windows with tabs, weird things happen when you try to dock them back onto the main surface.
Instead of letting you docking a tab into the middle of the empty surface, it lets you dock it in all directions, because the surface isn't really empty – it's a leaf with no tabs. Worst case scenario: if there's only one tab in a window and zero tabs in the main surface, then docking it back onto the main surface causes a panic.
thread 'main' panicked at /home/anghosh/Workspace/egui_dock/src/widgets/dock_area/show/window_surface.rs:62:33:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
0: rust_begin_unwind
at /rustc/b6d2d841bcf4b77343b159f134c7d39c2dd4ceaa/library/std/src/panicking.rs:645:5
1: core::panicking::panic_fmt
at /rustc/b6d2d841bcf4b77343b159f134c7d39c2dd4ceaa/library/core/src/panicking.rs:72:14
2: core::panicking::panic_bounds_check
at /rustc/b6d2d841bcf4b77343b159f134c7d39c2dd4ceaa/library/core/src/panicking.rs:208:5
3: <usize as core::slice::index::SliceIndex<[T]>>::index_mut
at /rustc/b6d2d841bcf4b77343b159f134c7d39c2dd4ceaa/library/core/src/slice/index.rs:263:14
4: core::slice::index::<impl core::ops::index::IndexMut<I> for [T]>::index_mut
at /rustc/b6d2d841bcf4b77343b159f134c7d39c2dd4ceaa/library/core/src/slice/index.rs:29:9
5: <alloc::vec::Vec<T,A> as core::ops::index::IndexMut<I>>::index_mut
at /rustc/b6d2d841bcf4b77343b159f134c7d39c2dd4ceaa/library/alloc/src/vec/mod.rs:2807:9
6: egui_dock::widgets::dock_area::show::window_surface::<impl egui_dock::widgets::dock_area::DockArea<Tab>>::show_window_surface
at ./src/widgets/dock_area/show/window_surface.rs:62:33
7: egui_dock::widgets::dock_area::show::<impl egui_dock::widgets::dock_area::DockArea<Tab>>::show_surface_inside
at ./src/widgets/dock_area/show/mod.rs:260:13
8: egui_dock::widgets::dock_area::show::<impl egui_dock::widgets::dock_area::DockArea<Tab>>::show_inside
at ./src/widgets/dock_area/show/mod.rs:87:13
9: egui_dock::widgets::dock_area::show::<impl egui_dock::widgets::dock_area::DockArea<Tab>>::show::{{closure}}
at ./src/widgets/dock_area/show/mod.rs:58:17
10: core::ops::function::FnOnce::call_once{{vtable.shim}}
at /rustc/b6d2d841bcf4b77343b159f134c7d39c2dd4ceaa/library/core/src/ops/function.rs:250:5
11: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
at /rustc/b6d2d841bcf4b77343b159f134c7d39c2dd4ceaa/library/alloc/src/boxed.rs:2016:9
12: egui::containers::panel::CentralPanel::show_inside_dyn::{{closure}}
at /home/anghosh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/egui-0.26.0/src/containers/panel.rs:1044:13
13: core::ops::function::FnOnce::call_once{{vtable.shim}}
at /rustc/b6d2d841bcf4b77343b159f134c7d39c2dd4ceaa/library/core/src/ops/function.rs:250:5
14: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
at /rustc/b6d2d841bcf4b77343b159f134c7d39c2dd4ceaa/library/alloc/src/boxed.rs:2016:9
15: egui::containers::frame::Frame::show_dyn
at /home/anghosh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/egui-0.26.0/src/containers/frame.rs:270:19
16: egui::containers::frame::Frame::show
at /home/anghosh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/egui-0.26.0/src/containers/frame.rs:261:9
17: egui::containers::panel::CentralPanel::show_inside_dyn
at /home/anghosh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/egui-0.26.0/src/containers/panel.rs:1042:9
18: egui::containers::panel::CentralPanel::show_dyn
at /home/anghosh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/egui-0.26.0/src/containers/panel.rs:1070:30
19: egui::containers::panel::CentralPanel::show
at /home/anghosh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/egui-0.26.0/src/containers/panel.rs:1054:9
20: egui_dock::widgets::dock_area::show::<impl egui_dock::widgets::dock_area::DockArea<Tab>>::show
at ./src/widgets/dock_area/show/mod.rs:51:9
21: <tab_add::MyApp as eframe::epi::App>::update
at ./examples/tab_add.rs:59:9
22: eframe::native::epi_integration::EpiIntegration::update::{{closure}}
at /home/anghosh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/eframe-0.26.0/src/native/epi_integration.rs:284:17
23: egui::context::Context::run
at /home/anghosh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/egui-0.26.0/src/context.rs:736:9
24: eframe::native::epi_integration::EpiIntegration::update
at /home/anghosh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/eframe-0.26.0/src/native/epi_integration.rs:277:27
25: eframe::native::glow_integration::GlowWinitRunning::run_ui_and_paint
at /home/anghosh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/eframe-0.26.0/src/native/glow_integration.rs:578:13
26: <eframe::native::glow_integration::GlowWinitApp as eframe::native::winit_integration::WinitApp>::run_ui_and_paint
at /home/anghosh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/eframe-0.26.0/src/native/glow_integration.rs:402:13
27: eframe::native::run::run_and_return::{{closure}}
at /home/anghosh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/eframe-0.26.0/src/native/run.rs:99:17
28: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
at /rustc/b6d2d841bcf4b77343b159f134c7d39c2dd4ceaa/library/core/src/ops/function.rs:294:13
29: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
at /rustc/b6d2d841bcf4b77343b159f134c7d39c2dd4ceaa/library/core/src/ops/function.rs:294:13
30: winit::platform_impl::platform::x11::EventLoop<T>::single_iteration
at /home/anghosh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.10/src/platform_impl/linux/x11/mod.rs:608:17
31: winit::platform_impl::platform::x11::EventLoop<T>::poll_events_with_timeout
at /home/anghosh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.10/src/platform_impl/linux/x11/mod.rs:547:9
32: winit::platform_impl::platform::x11::EventLoop<T>::pump_events
at /home/anghosh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.10/src/platform_impl/linux/x11/mod.rs:453:13
33: winit::platform_impl::platform::x11::EventLoop<T>::run_on_demand
at /home/anghosh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.10/src/platform_impl/linux/x11/mod.rs:414:19
34: winit::platform_impl::platform::EventLoop<T>::run_on_demand
at /home/anghosh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.10/src/platform_impl/linux/mod.rs:821:56
35: <winit::event_loop::EventLoop<T> as winit::platform::run_on_demand::EventLoopExtRunOnDemand>::run_on_demand
at /home/anghosh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.10/src/platform/run_on_demand.rs:80:9
36: eframe::native::run::run_and_return
at /home/anghosh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/eframe-0.26.0/src/native/run.rs:76:5
37: eframe::native::run::run_glow::{{closure}}
at /home/anghosh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/eframe-0.26.0/src/native/run.rs:394:13
38: eframe::native::run::with_event_loop::{{closure}}
at /home/anghosh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/eframe-0.26.0/src/native/run.rs:58:12
39: std::thread::local::LocalKey<T>::try_with
at /rustc/b6d2d841bcf4b77343b159f134c7d39c2dd4ceaa/library/std/src/thread/local.rs:284:16
40: std::thread::local::LocalKey<T>::with
at /rustc/b6d2d841bcf4b77343b159f134c7d39c2dd4ceaa/library/std/src/thread/local.rs:260:9
41: eframe::native::run::with_event_loop
at /home/anghosh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/eframe-0.26.0/src/native/run.rs:48:5
42: eframe::native::run::run_glow
at /home/anghosh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/eframe-0.26.0/src/native/run.rs:392:16
43: eframe::run_native
at /home/anghosh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/eframe-0.26.0/src/lib.rs:262:13
44: tab_add::main
at ./examples/tab_add.rs:9:5
45: core::ops::function::FnOnce::call_once
at /rustc/b6d2d841bcf4b77343b159f134c7d39c2dd4ceaa/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
No description provided.