From de33a0da7cabb1e295d137b698ead62651f573e8 Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Fri, 16 Aug 2024 11:37:45 +0200 Subject: [PATCH 1/2] Fix error when trying to clear non-existant component --- crates/viewer/re_selection_panel/src/defaults_ui.rs | 2 +- crates/viewer/re_selection_panel/src/visualizer_ui.rs | 4 ++-- crates/viewer/re_space_view/src/view_property_ui.rs | 2 +- .../viewer/re_viewer_context/src/blueprint_helpers.rs | 11 +++++------ .../re_viewer_context/src/space_view/view_context.rs | 4 ++-- .../re_viewport_blueprint/src/view_properties.rs | 2 +- 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/crates/viewer/re_selection_panel/src/defaults_ui.rs b/crates/viewer/re_selection_panel/src/defaults_ui.rs index f360e3ee6e68..b9cd4e017b0c 100644 --- a/crates/viewer/re_selection_panel/src/defaults_ui.rs +++ b/crates/viewer/re_selection_panel/src/defaults_ui.rs @@ -146,7 +146,7 @@ fn active_default_ui( re_ui::list_item::PropertyContent::new(component_name.short_name()) .min_desired_width(150.0) .action_button(&re_ui::icons::CLOSE, || { - ctx.save_empty_blueprint_component_by_name( + ctx.clear_blueprint_component_by_name( &view.defaults_path, component_name, ); diff --git a/crates/viewer/re_selection_panel/src/visualizer_ui.rs b/crates/viewer/re_selection_panel/src/visualizer_ui.rs index a1be088d0a3e..b1b3731ec767 100644 --- a/crates/viewer/re_selection_panel/src/visualizer_ui.rs +++ b/crates/viewer/re_selection_panel/src/visualizer_ui.rs @@ -435,7 +435,7 @@ fn editable_blueprint_component_list_item( .action_button(&re_ui::icons::CLOSE, || { query_ctx .viewer_ctx - .save_empty_blueprint_component_by_name(blueprint_path, component); + .clear_blueprint_component_by_name(blueprint_path, component); }), ) } @@ -457,7 +457,7 @@ fn menu_more( .on_disabled_hover_text("There's no override active") .clicked() { - ctx.save_empty_blueprint_component_by_name(override_path, component_name); + ctx.clear_blueprint_component_by_name(override_path, component_name); ui.close_menu(); } diff --git a/crates/viewer/re_space_view/src/view_property_ui.rs b/crates/viewer/re_space_view/src/view_property_ui.rs index 24f11d8cc77b..89ee31df2e59 100644 --- a/crates/viewer/re_space_view/src/view_property_ui.rs +++ b/crates/viewer/re_space_view/src/view_property_ui.rs @@ -218,7 +218,7 @@ This has the same effect as not setting the value in the blueprint at all." ) .on_disabled_hover_text("The property is already unset."); if response.clicked() { - ctx.save_empty_blueprint_component_by_name(blueprint_path, component_name); + ctx.clear_blueprint_component_by_name(blueprint_path, component_name); ui.close_menu(); } diff --git a/crates/viewer/re_viewer_context/src/blueprint_helpers.rs b/crates/viewer/re_viewer_context/src/blueprint_helpers.rs index e7944f06b7af..20e23074ace4 100644 --- a/crates/viewer/re_viewer_context/src/blueprint_helpers.rs +++ b/crates/viewer/re_viewer_context/src/blueprint_helpers.rs @@ -144,12 +144,14 @@ impl ViewerContext<'_> { { self.save_blueprint_array(entity_path, component_name, default_value); } else { - self.save_empty_blueprint_component_by_name(entity_path, component_name); + self.clear_blueprint_component_by_name(entity_path, component_name); } } /// Helper to save a component to the blueprint store. - pub fn save_empty_blueprint_component_by_name( + /// + /// Does nothing if the component doesn't exist at that path. + pub fn clear_blueprint_component_by_name( &self, entity_path: &EntityPath, component_name: ComponentName, @@ -164,10 +166,7 @@ impl ViewerContext<'_> { .map(|array| array.data_type().clone()) }) else { - re_log::error!( - "Tried to clear a component with unknown type: {}", - component_name - ); + // There's no component at this path yet, so there's nothing to clear. return; }; diff --git a/crates/viewer/re_viewer_context/src/space_view/view_context.rs b/crates/viewer/re_viewer_context/src/space_view/view_context.rs index a242c43caf61..3b21dd385ef8 100644 --- a/crates/viewer/re_viewer_context/src/space_view/view_context.rs +++ b/crates/viewer/re_viewer_context/src/space_view/view_context.rs @@ -152,13 +152,13 @@ impl<'a> ViewContext<'a> { } #[inline] - pub fn save_empty_blueprint_component_by_name( + pub fn clear_blueprint_component_by_name( &self, entity_path: &EntityPath, component_name: ComponentName, ) { self.viewer_ctx - .save_empty_blueprint_component_by_name(entity_path, component_name); + .clear_blueprint_component_by_name(entity_path, component_name); } #[inline] diff --git a/crates/viewer/re_viewport_blueprint/src/view_properties.rs b/crates/viewer/re_viewport_blueprint/src/view_properties.rs index dff63290f848..03572bdb9a39 100644 --- a/crates/viewer/re_viewport_blueprint/src/view_properties.rs +++ b/crates/viewer/re_viewport_blueprint/src/view_properties.rs @@ -191,7 +191,7 @@ impl<'a> ViewProperty<'a> { /// Resets all components to empty values, i.e. the fallback. pub fn reset_all_components_to_empty(&self, ctx: &'a ViewerContext<'a>) { for &component_name in self.query_results.components.keys() { - ctx.save_empty_blueprint_component_by_name(&self.blueprint_store_path, component_name); + ctx.clear_blueprint_component_by_name(&self.blueprint_store_path, component_name); } } From 36f46d383adf85f804b5ed97e53e61bcc932e5e5 Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Fri, 16 Aug 2024 13:07:44 +0200 Subject: [PATCH 2/2] fix incorrect docstring --- crates/viewer/re_viewer_context/src/blueprint_helpers.rs | 4 +--- .../viewer/re_viewer_context/src/space_view/view_context.rs | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/viewer/re_viewer_context/src/blueprint_helpers.rs b/crates/viewer/re_viewer_context/src/blueprint_helpers.rs index 20e23074ace4..e2612d9871ad 100644 --- a/crates/viewer/re_viewer_context/src/blueprint_helpers.rs +++ b/crates/viewer/re_viewer_context/src/blueprint_helpers.rs @@ -148,9 +148,7 @@ impl ViewerContext<'_> { } } - /// Helper to save a component to the blueprint store. - /// - /// Does nothing if the component doesn't exist at that path. + /// Clears a component in the blueprint store by logging an empty array if it exists. pub fn clear_blueprint_component_by_name( &self, entity_path: &EntityPath, diff --git a/crates/viewer/re_viewer_context/src/space_view/view_context.rs b/crates/viewer/re_viewer_context/src/space_view/view_context.rs index 3b21dd385ef8..264417df39ff 100644 --- a/crates/viewer/re_viewer_context/src/space_view/view_context.rs +++ b/crates/viewer/re_viewer_context/src/space_view/view_context.rs @@ -151,6 +151,7 @@ impl<'a> ViewContext<'a> { .reset_blueprint_component_by_name(entity_path, component_name); } + /// Clears a component in the blueprint store by logging an empty array if it exists. #[inline] pub fn clear_blueprint_component_by_name( &self,