Skip to content

Commit

Permalink
Close file handle in LoadMD. Refs #5320
Browse files Browse the repository at this point in the history
Windows requires all file handles to be closed before anything can be
deleted. The handle is only closed for the histo case and is deleted
if no backend is being used.
  • Loading branch information
martyngigg committed May 17, 2012
1 parent 109d58a commit 3db7df8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 6 additions & 0 deletions Code/Mantid/Framework/MDEvents/src/LoadMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ namespace Mantid
// MDHistoWorkspace case.
this->loadHisto();
}
if(!fileBacked)
{
delete file;
}
}


Expand Down Expand Up @@ -328,6 +332,8 @@ namespace Mantid
this->loadSlab("num_events", ws->getNumEventsArray(), ws, ::NeXus::FLOAT64);
this->loadSlab("mask", ws->getMaskArray(), ws, ::NeXus::INT8);

file->close();

// Save to output
setProperty("OutputWorkspace", boost::dynamic_pointer_cast<IMDWorkspace>(ws));
}
Expand Down
8 changes: 0 additions & 8 deletions Code/Mantid/Framework/MDEvents/test/LoadMDTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -504,26 +504,18 @@ class LoadMDTest : public CxxTest::TestSuite

void test_histo2()
{
// Fails on windows with file access error
#ifndef _WIN32
MDHistoWorkspace_sptr ws = MDEventsTestHelper::makeFakeMDHistoWorkspace(2.5, 2, 10, 10.0, 3.5, "histo2", 4.5);
doTestHisto(ws);
#endif
}

void test_histo3()
{
// Fails on windows with file access error
#ifndef _WIN32
MDHistoWorkspace_sptr ws = MDEventsTestHelper::makeFakeMDHistoWorkspace(2.5, 3, 4, 10.0, 3.5, "histo3", 4.5);
doTestHisto(ws);
#endif
}


};


#endif /* MANTID_MDEVENTS_LOADMDEWTEST_H_ */


0 comments on commit 3db7df8

Please sign in to comment.