(io): Mesh attributes created after getInput aren't locked
Summary
When using getLockedInput/InOut
on a ::fwData::Mesh
, shared_ptr
or weak_ptr
only locks buffer array that are already been created (points, cells, ...), but if others array are created afterwards (points_colors, normals) they aren't locked.
See the buffer lock function of fwData::Mesh
, colors/normals and tex coords are skipped if they don't already exists.
Mesh::LocksType Mesh::lock() const
{
LocksType locks;
locks.push_back(m_points->lock());
locks.push_back(m_cellTypes->lock());
locks.push_back(m_cellData->lock());
locks.push_back(m_cellDataOffsets->lock());
if (m_pointColors)
{
locks.push_back(m_pointColors->lock());
}
if (m_cellColors)
{
locks.push_back(m_cellColors->lock());
}
if (m_pointNormals)
{
locks.push_back(m_pointNormals->lock());
}
if (m_cellNormals)
{
locks.push_back(m_cellNormals->lock());
}
if (m_cellTexCoords)
{
locks.push_back(m_cellTexCoords->lock());
}
if (m_pointTexCoords)
{
locks.push_back(m_pointTexCoords->lock());
}
return locks;
}
Steps to reproduce
Apply the attached patch file, and then compile and run TestLockMesh
Relevant logs and/or screenshots
Output of TestMeshLock
1. Mesh should be locked and dump locked
2. Reserve 30 points with POINT_COLORS
3. Push Points
4. Push Points
5. Set Point color, color_points array isn't locked !
[1][00:00:00.500441][error] /home/mschweitzer/dev/sight/src/sight/libs/core/fwServices/src/fwServices/IService.cpp:741: Error while UPDATING service 'MeshLockIssue' : The buffer cannot be accessed if the array is not locked for dump (see lock())
Possible fixes
-
One possible fix is to initialize all arrays as empty arrays in constructor, so when performing the lock the first time all arrays will be locked.
-
Make sure to clean unnecessary arrays content, when setting attributes ex: update from cells to color array ?
-
Add the patch as a unit test in ::fwData::Mesh test