Skip to content

Commit

Permalink
Clear blueprint via command-sender
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs committed Dec 14, 2023
1 parent e9a08cd commit 85ca6c2
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions crates/re_viewer/src/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use re_smart_channel::ReceiveSet;
use re_space_view::DataQuery as _;
use re_viewer_context::{
AppOptions, Caches, CommandSender, ComponentUiRegistry, PlayState, RecordingConfig,
SelectionState, SpaceViewClassRegistry, StoreContext, ViewerContext,
SelectionState, SpaceViewClassRegistry, StoreContext, SystemCommandSender as _, ViewerContext,
};
use re_viewport::{
identify_entities_per_system_per_class, SpaceInfoCollection, Viewport, ViewportState,
Expand Down Expand Up @@ -104,7 +104,20 @@ impl AppState {
viewport_state,
} = self;

let mut viewport = Viewport::from_db(store_context.blueprint, viewport_state);
let viewport = Viewport::from_db(store_context.blueprint, viewport_state);

// If the blueprint is invalid, reset it.
if viewport.blueprint.is_invalid() {
re_log::warn!("Incompatible blueprint detected. Resetting to default.");
command_sender.send_system(re_viewer_context::SystemCommand::ResetBlueprint);

// The blueprint isn't valid so nothing past this is going to work properly.
// we might as well return and it will get fixed on the next frame.

// TODO(jleibs): If we move viewport loading up to a context where the StoreDb is mutable
// we can run the clear and re-load.
return;
}

recording_config_entry(recording_configs, store_db.store_id().clone(), store_db)
.selection_state
Expand All @@ -125,7 +138,7 @@ impl AppState {
viewport
.blueprint
.space_views
.values_mut()
.values()
.flat_map(|space_view| {
space_view.queries.iter().map(|query| {
let resolver =
Expand Down Expand Up @@ -163,12 +176,6 @@ impl AppState {
// have the latest information.
let spaces_info = SpaceInfoCollection::new(ctx.store_db);

// If the blueprint is invalid, reset it.
if viewport.blueprint.is_invalid() {
re_log::warn!("Incompatible blueprint detected. Resetting to default.");
viewport.blueprint.reset(&ctx, &spaces_info);
}

viewport.on_frame_start(&ctx, &spaces_info);

// TODO(jleibs): Running the queries a second time is annoying, but we need
Expand Down

0 comments on commit 85ca6c2

Please sign in to comment.