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

Early-out on zero-sized space-views to prevent crashes #1623

Merged
merged 1 commit into from
Mar 20, 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
5 changes: 5 additions & 0 deletions crates/re_viewer/src/ui/space_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ impl SpaceView {
) {
crate::profile_function!();

let is_zero_sized_viewport = ui.available_size().min_elem() <= 0.0;
if is_zero_sized_viewport {
return;
}

let query = crate::ui::scene::SceneQuery {
entity_paths: self.data_blueprint.entity_paths(),
timeline: *ctx.rec_cfg.time_ctrl.timeline(),
Expand Down
4 changes: 4 additions & 0 deletions crates/re_viewer/src/ui/view_spatial/ui_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ fn view_2d_scrollable(
let (mut response, painter) =
parent_ui.allocate_painter(desired_size, egui::Sense::click_and_drag());

if !response.rect.is_positive() {
return response; // protect against problems with zero-sized views
}

// Create our transforms.
let ui_from_space = egui::emath::RectTransform::from_to(scene_rect_accum, response.rect);
let space_from_ui = ui_from_space.inverse();
Expand Down
4 changes: 4 additions & 0 deletions crates/re_viewer/src/ui/view_spatial/ui_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ pub fn view_3d(
let (rect, mut response) =
ui.allocate_at_least(ui.available_size(), egui::Sense::click_and_drag());

if !rect.is_positive() {
return; // protect against problems with zero-sized views
}

// If we're tracking a camera right now, we want to make it slightly sticky,
// so that a click on some entity doesn't immediately break the tracked state.
// (Threshold is in amount of ui points the mouse was moved.)
Expand Down