G-Node / nix

Neuroscience information exchange format
https://readthedocs.org/projects/nixio/
Other
66 stars 36 forks source link

strange behavior with deleted entities. #565

Closed jgrewe closed 8 years ago

jgrewe commented 8 years ago

I found the following code in the tests:

 l1n1.deleteSection(l2n2.id());
...
 CPPUNIT_ASSERT(!l1n1.hasSection(l2n2));

This looks cool, but is really strange. In the first line section l2n2 is deleted, and in the last line we ask whether it exists. Section::hasSection(section) does return backend()->hasSection(section.id()); looks ok, but in this context it should fail! We deleted l2n2 from the file. The l2n2 variable, is not None, however. The strange thing is, that we can ask for its name, or id and get proper results, even though it was deleted just moments before. Why is this possible? Probably because hdf5 caches or does not flush between the two lines in the code. The previous test fails in the file-backend because l2n2 does no longer exist.

Imho, the hasSection(), and probably all other hasXYZ() functions should be changed to catch the possibility that the entity has been deleted but is not none. I do not like try catch statements that much, but it would be one option.

jgrewe commented 8 years ago

solved via pull requests #566 and #567