diff --git a/crates/viewer/re_ui/src/command.rs b/crates/viewer/re_ui/src/command.rs index 904922ef5379..f997ef524307 100644 --- a/crates/viewer/re_ui/src/command.rs +++ b/crates/viewer/re_ui/src/command.rs @@ -78,6 +78,9 @@ pub enum UICommand { #[cfg(not(target_arch = "wasm32"))] PrintPrimaryCache, + #[cfg(debug_assertions)] + ResetEguiMemory, + #[cfg(target_arch = "wasm32")] CopyDirectLink, @@ -232,6 +235,11 @@ impl UICommand { "Prints the state of the entire primary cache to the console and clipboard. WARNING: this may be A LOT of text.", ), + #[cfg(debug_assertions)] + Self::ResetEguiMemory => ( + "Reset egui memory", + "Reset egui memory, useful for debugging UI code.", + ), #[cfg(target_arch = "wasm32")] Self::CopyDirectLink => ( @@ -340,6 +348,9 @@ impl UICommand { #[cfg(not(target_arch = "wasm32"))] Self::PrintPrimaryCache => None, + #[cfg(debug_assertions)] + Self::ResetEguiMemory => None, + #[cfg(target_arch = "wasm32")] Self::CopyDirectLink => None, diff --git a/crates/viewer/re_viewer/src/app.rs b/crates/viewer/re_viewer/src/app.rs index 9702e09a408c..b28637251b1c 100644 --- a/crates/viewer/re_viewer/src/app.rs +++ b/crates/viewer/re_viewer/src/app.rs @@ -766,6 +766,14 @@ impl App { } } + #[cfg(debug_assertions)] + UICommand::ResetEguiMemory => { + egui_ctx.memory_mut(|mem| *mem = Default::default()); + + // re-apply style, which is lost when resetting memory + re_ui::apply_style_and_install_loaders(egui_ctx); + } + #[cfg(target_arch = "wasm32")] UICommand::CopyDirectLink => { self.run_copy_direct_link_command(store_context);