The following code fails as soon as entity variables that were used in further assignments like da.unit("mV") are reused. As in nixpy, explicitely setting them to nix::none solves the problem.
#include "nix.hpp"
void create_files(int count) {
nix::File f;
nix::Block b;
nix::DataArray da;
std::vector<double> data;
for(int i = 0; i < 1000; i ++) {
data.push_back(i * 3.14);
}
for (int i = 0; i < count; i++) {
f = nix::File::open("test_file_" + nix::util::numToStr(i) + ".h5", nix::FileMode::Overwrite);
b = f.createBlock("block", "test");
da = b.createDataArray("array", "test", data);
da.unit("mV"); // comment to have it running
f.close();
}
}
void reopen_files(int count) {
nix::File f;
nix::Block b;
nix::DataArray da;
std::vector<double> data;
for (int i = 0; i < count; i++) {
f = nix::File::open("test_file_" + nix::util::numToStr(i) + ".h5", nix::FileMode::ReadOnly);
b = f.getBlock("block");
da = b.getDataArray("array");
std::cerr << da.id() << std::endl;
da = nix::none; // comment to have it crashing
b = nix::none; // do
f.close();
}
}
int main(int argc, char* argv[]) {
create_files(10);
reopen_files(10);
return 0;
}
btw., the issue does not arise in the file-backend..,
This is the same bug as in nixpy (https://github.com/G-Node/nixpy/issues/138), and probably the source of it.
The following code fails as soon as entity variables that were used in further assignments like
da.unit("mV")
are reused. As in nixpy, explicitely setting them tonix::none
solves the problem.btw., the issue does not arise in the file-backend..,