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

Add a command palette action to reset egui's memory (debug build only) #7446

Merged
merged 2 commits into from
Sep 19, 2024
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
11 changes: 11 additions & 0 deletions crates/viewer/re_ui/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ pub enum UICommand {
#[cfg(not(target_arch = "wasm32"))]
PrintPrimaryCache,

#[cfg(debug_assertions)]
ResetEguiMemory,

#[cfg(target_arch = "wasm32")]
CopyDirectLink,

Expand Down Expand Up @@ -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 => (
Expand Down Expand Up @@ -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,

Expand Down
8 changes: 8 additions & 0 deletions crates/viewer/re_viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading