Skip to content

Commit 5e8058c

Browse files
committed
Add nullptr check to MeshBuffer loaded from HDF5 file
1 parent 73114c7 commit 5e8058c

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

rviz_mesh_tools_plugins/src/MapDisplay.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,15 @@ void MapDisplay::updateMap()
331331

332332
// Load geometry and clusters
333333
bool successful = loadData();
334-
if (!successful)
334+
if (successful)
335335
{
336+
enableClusterLabelDisplay();
337+
enableMeshDisplay();
338+
}
339+
else
340+
{
341+
disableClusterLabelDisplay();
342+
disableMeshDisplay();
336343
return;
337344
}
338345

@@ -426,7 +433,7 @@ bool MapDisplay::loadData()
426433

427434
try
428435
{
429-
if (boost::filesystem::extension(mapFile).compare(".h5") == 0)
436+
if (boost::filesystem::path(mapFile).extension().compare(".h5") == 0)
430437
{
431438
enableClusterLabelDisplay(); // enable label writing to hdf5
432439
enableMeshDisplay();
@@ -443,6 +450,16 @@ bool MapDisplay::loadData()
443450
hdf5_mesh_io->open(mapFile);
444451
auto mesh_buffer = hdf5_mesh_io->MeshIO::load(mesh_part);
445452

453+
if (nullptr == mesh_buffer)
454+
{
455+
RCLCPP_ERROR(
456+
rclcpp::get_logger("rviz_mesh_tools_plugins"),
457+
"Could not find a mesh with name '%s' in HDF5 file '%s'",
458+
mesh_part.c_str(), mapFile.c_str()
459+
);
460+
return false;
461+
}
462+
446463
// the mesh buffer is a map from a string to a Channel
447464
// example:
448465
// "vertices" -> Channel<float>

0 commit comments

Comments
 (0)