Skip to content
Snippets Groups Projects
Commit 0a19cb0d authored by Michael Wedel's avatar Michael Wedel
Browse files

Refs #15129. Fix crash in instrument view

This covers the case when there are 0 peaks in the PeaksWorkspace, which I had forgotten about earlier.
parent 8704983c
No related branches found
No related tags found
No related merge requests found
...@@ -103,6 +103,9 @@ QString PeakHKL::formatNumber(double h, int prec) { ...@@ -103,6 +103,9 @@ QString PeakHKL::formatNumber(double h, int prec) {
/// Extract minimum and maximum intensity from peaks workspace for scaling. /// Extract minimum and maximum intensity from peaks workspace for scaling.
void AbstractIntensityScale::setPeaksWorkspace( void AbstractIntensityScale::setPeaksWorkspace(
const boost::shared_ptr<Mantid::API::IPeaksWorkspace> &pws) { const boost::shared_ptr<Mantid::API::IPeaksWorkspace> &pws) {
m_maxIntensity = 0.0;
m_minIntensity = 0.0;
if (pws) { if (pws) {
int peakCount = pws->getNumberPeaks(); int peakCount = pws->getNumberPeaks();
...@@ -116,11 +119,10 @@ void AbstractIntensityScale::setPeaksWorkspace( ...@@ -116,11 +119,10 @@ void AbstractIntensityScale::setPeaksWorkspace(
auto minMaxIntensity = auto minMaxIntensity =
std::minmax_element(intensities.begin(), intensities.end()); std::minmax_element(intensities.begin(), intensities.end());
m_maxIntensity = *minMaxIntensity.second; if (peakCount > 0) {
m_minIntensity = *minMaxIntensity.first; m_maxIntensity = *minMaxIntensity.second;
} else { m_minIntensity = *minMaxIntensity.first;
m_maxIntensity = 0.0; }
m_minIntensity = 0.0;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment