Skip to content

Fix problem with ArrayCopy of two of the same arrays

A recent modification to ArrayCopy created a fast path for when copying arrays of the same type. This fast path just deep copies the buffers. The issue was that the buffer copy was creating new buffers instead of updating the existing buffers. The passed in ArrayHandle would get updated to the new buffers, but any other ArrayHandles sharing those buffers would still have the old versions. That would lead to unexpected errors in code like this.

vtkm::cont::ArrayHandle<T> outArray1;
vtkm::cont::ArrayHandle<T> outArray2 = outArray1;

vtkm::cont::ArrayCopy(inArray, outArray2);

If inArray was a different type than outArray2, then the data for both outArray1 and outArray2 would be updated (which is the expected behavior for something considered a "pointer"). However, if inArray was the same type as outArray2, then the fast path would change outArray2 but leave outArray1 the same.

This behavior has been corrected so that, in this case, the data of outArray1 always follows that of outArray2.

Merge request reports

Loading