Skip to content

Commit f23a3a2

Browse files
authored
Remove warning "Cannot find root container" (#8058)
* Closes #8051 * Related to #8051 ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
1 parent 5a39a30 commit f23a3a2

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

crates/viewer/re_blueprint_tree/src/blueprint_tree.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,9 @@ impl BlueprintTree {
187187
let container_id = blueprint.root_container;
188188

189189
let Some(container_blueprint) = blueprint.containers.get(&container_id) else {
190-
re_log::warn_once!("Cannot find root container {container_id}");
190+
// This happens after a blueprint reset (or there was no blueprint).
191+
// TODO(#8056): refactor all of this
192+
re_log::debug!("Cannot find root {container_id} in BlueprintTree (b/c recent reset?)");
191193
return;
192194
};
193195

crates/viewer/re_viewport/src/viewport.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ impl<'a> Viewport<'a> {
246246
reset = true;
247247
} else {
248248
let parent_id = parent_container.unwrap_or(self.blueprint.root_container);
249+
re_log::trace!("Adding space-view {space_view_id} to parent {parent_id}");
249250
let tile_id = self.tree.tiles.insert_pane(space_view_id);
250251
let container_tile_id = blueprint_id_to_tile_id(&parent_id);
251252
if let Some(egui_tiles::Tile::Container(container)) =
@@ -262,7 +263,7 @@ impl<'a> Viewport<'a> {
262263
);
263264
}
264265
} else {
265-
re_log::trace!("Root was not a container - will re-run auto-layout");
266+
re_log::trace!("Parent was not a container - will re-run auto-layout");
266267
reset = true;
267268
}
268269
}
@@ -275,6 +276,7 @@ impl<'a> Viewport<'a> {
275276
.tree
276277
.tiles
277278
.insert_container(egui_tiles::Container::new(container_kind, vec![]));
279+
re_log::trace!("Adding container {container_kind:?} to parent {parent_id}");
278280
if let Some(egui_tiles::Tile::Container(container)) =
279281
self.tree.tiles.get_mut(blueprint_id_to_tile_id(&parent_id))
280282
{

crates/viewer/re_viewport_blueprint/src/viewport_blueprint.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ impl ViewportBlueprint {
9292
past_viewer_recommendations: results.component_batch(),
9393
};
9494

95+
let root_container: Option<ContainerId> = root_container.map(|id| id.0.into());
96+
re_log::trace_once!("Loaded root_container: {root_container:?}");
97+
9598
let all_space_view_ids: Vec<SpaceViewId> = blueprint_db
9699
.tree()
97100
.children
@@ -143,19 +146,19 @@ impl ViewportBlueprint {
143146
let tree = build_tree_from_space_views_and_containers(
144147
space_views.values(),
145148
containers.values(),
146-
root_container.clone(),
149+
root_container,
147150
);
148151

152+
re_log::trace_once!("Loaded tree: {tree:#?}");
153+
149154
let past_viewer_recommendations = past_viewer_recommendations
150155
.unwrap_or_default()
151156
.iter()
152157
.cloned()
153158
.collect();
154159

155-
let root_container_or_placeholder = root_container.clone().map_or_else(
156-
|| ContainerId::hashed_from_str("placeholder_root_container"),
157-
|id| id.0.into(),
158-
);
160+
let root_container_or_placeholder = root_container
161+
.unwrap_or_else(|| ContainerId::hashed_from_str("placeholder_root_container"));
159162

160163
Self {
161164
space_views,
@@ -909,7 +912,7 @@ impl ViewportBlueprint {
909912
fn build_tree_from_space_views_and_containers<'a>(
910913
space_views: impl Iterator<Item = &'a SpaceViewBlueprint>,
911914
containers: impl Iterator<Item = &'a ContainerBlueprint>,
912-
root_container: Option<RootContainer>,
915+
root_container: Option<ContainerId>,
913916
) -> egui_tiles::Tree<SpaceViewId> {
914917
re_tracing::profile_function!();
915918
let mut tree = egui_tiles::Tree::empty("viewport_tree");
@@ -933,7 +936,6 @@ fn build_tree_from_space_views_and_containers<'a>(
933936
// And finally, set the root
934937

935938
if let Some(root_container) = root_container {
936-
let root_container = ContainerId::from(root_container.0);
937939
tree.root = Some(blueprint_id_to_tile_id(&root_container));
938940
}
939941

0 commit comments

Comments
 (0)