Closed achilleas-k closed 7 years ago
the other solution to the problem would be to disallow adding data_arrays from different blocks... This is, what we do in MultiTags for example.
if (!block()->hasDataArray(name_or_id))
throw std::runtime_error("MultiTagHDF5::positions: DataArray not found in block!");
But that's already there. That's the rule. The problem comes from name ambiguity between DAs on different blocks.
To elaborate: the append succeeds not because dtwo
is successfully linked to the group, but because the append method finds done
by name.
solved via #674
Demonstration of problem
Consider the following example program:
The line where
dtwo
is added togrp
viadataArrays(<vector>)
succeeds even though it should fail. However, the object that gets appended isn't the one given to the method.Output
Sample output of the program:
Description of behaviour
The
dataArrays()
method (https://github.com/G-Node/nix/blob/master/backend/hdf5/GroupHDF5.cpp#L108) extracts the names from the provided vector of DataArrays. It uses the names to check if the parent block contains the provided DataArrays. If it finds the DataArrays in question, it extracts their ID and passes each ID on to theaddDataArray
function.The problem occurs when a DataArray passed to the
dataArrays()
method has the same name as a DataArray in the parent block, but is not the same object (different ID and presumably different data). The valid object gets appended, i.e., the DataArray that exists on the parent object, but this is not the DataArray that the user provided.Solution
Once an object is obtained from the parent Block, compare the IDs as well.