From 725815177a0c868b476e9f1a4131cdb4ec3bc99d Mon Sep 17 00:00:00 2001 From: Michael Grupp Date: Fri, 19 Oct 2018 08:27:58 +0200 Subject: [PATCH] Fix Clang thread-safety warning. (#1068) reading variable 'submap_slices_' requires holding mutex 'mutex_' [-Wthread-safety-analysis] --- cartographer_ros/cartographer_ros/occupancy_grid_node_main.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cartographer_ros/cartographer_ros/occupancy_grid_node_main.cc b/cartographer_ros/cartographer_ros/occupancy_grid_node_main.cc index 0a3d51f..1703d66 100644 --- a/cartographer_ros/cartographer_ros/occupancy_grid_node_main.cc +++ b/cartographer_ros/cartographer_ros/occupancy_grid_node_main.cc @@ -164,11 +164,10 @@ void Node::HandleSubmapList( } void Node::DrawAndPublish(const ::ros::WallTimerEvent& unused_timer_event) { + absl::MutexLock locker(&mutex_); if (submap_slices_.empty() || last_frame_id_.empty()) { return; } - - absl::MutexLock locker(&mutex_); auto painted_slices = PaintSubmapSlices(submap_slices_, resolution_); std::unique_ptr msg_ptr = CreateOccupancyGridMsg( painted_slices, resolution_, last_frame_id_, last_timestamp_);