Skip to content

Commit

Permalink
Refs #4543, #4524: possible fix for crash in LineViewer
Browse files Browse the repository at this point in the history
involving 0-length lines being drawn
  • Loading branch information
Janik Zikovsky committed Jan 18, 2012
1 parent 53ca3c3 commit aa2b0e2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Code/Mantid/Framework/MDEvents/src/SlicingAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,20 +115,26 @@ namespace MDEvents
Strings::convert(strs[ strs.size()-1 ], numBins);
max = double(numBins);
if (name.size() == 0)
throw std::invalid_argument("Name should not be blank.");
throw std::invalid_argument("name should not be blank.");
if (numBins < 1)
throw std::invalid_argument("Number of bins should be >= 1.");
throw std::invalid_argument("number of bins should be >= 1.");

double length = 0.0;
Strings::convert(strs[ strs.size()-2 ], length);
min = 0.0;
max = length;

if (length <= 0)
throw std::invalid_argument("'length' parameter should be > 0.0.");

// Create the basis vector with the right # of dimensions
VMD basis(this->m_inWS->getNumDims());
for (size_t d=0; d<this->m_inWS->getNumDims(); d++)
Strings::convert(strs[d+2], basis[d]);
basis.normalize();
double oldBasisLength = basis.normalize();

if (oldBasisLength <= 0)
throw std::invalid_argument("direction should not be 0-length.");

// Now, convert the basis vector to the coordinates of the ORIGNAL ws, if any
if (m_originalWS)
Expand Down

0 comments on commit aa2b0e2

Please sign in to comment.