Skip to content

Commit

Permalink
Refs #10276 Fix crash related to Stitch1DMany
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry Jeffery committed Sep 25, 2014
1 parent 709aedd commit 96afad8
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions Code/Mantid/Framework/Algorithms/src/Stitch1DMany.cpp
Expand Up @@ -78,31 +78,38 @@ namespace Mantid
}

//Check that all the workspaces are of the same type
const std::string id = m_inputWorkspaces[0]->id();
for(auto it = m_inputWorkspaces.begin(); it != m_inputWorkspaces.end(); ++it)
if(m_inputWorkspaces.size() > 0)
{
if((*it)->id() != id)
const std::string id = m_inputWorkspaces[0]->id();
for(auto it = m_inputWorkspaces.begin(); it != m_inputWorkspaces.end(); ++it)
{
errors["InputWorkspaces"] = "All workspaces must be the same type.";
break;
if((*it)->id() != id)
{
errors["InputWorkspaces"] = "All workspaces must be the same type.";
break;
}
}
}

//If our inputs are all group workspaces, check they're the same size
WorkspaceGroup_sptr firstGroup = boost::dynamic_pointer_cast<WorkspaceGroup>(m_inputWorkspaces[0]);
if(firstGroup)
{
size_t groupSize = firstGroup->size();
for(auto it = m_inputWorkspaces.begin(); it != m_inputWorkspaces.end(); ++it)
//If our inputs are all group workspaces, check they're the same size
WorkspaceGroup_sptr firstGroup = boost::dynamic_pointer_cast<WorkspaceGroup>(m_inputWorkspaces[0]);
if(firstGroup)
{
WorkspaceGroup_sptr group = boost::dynamic_pointer_cast<WorkspaceGroup>(*it);
if(group->size() != groupSize)
size_t groupSize = firstGroup->size();
for(auto it = m_inputWorkspaces.begin(); it != m_inputWorkspaces.end(); ++it)
{
errors["InputWorkspaces"] = "All group workspaces must be the same size.";
break;
WorkspaceGroup_sptr group = boost::dynamic_pointer_cast<WorkspaceGroup>(*it);
if(group->size() != groupSize)
{
errors["InputWorkspaces"] = "All group workspaces must be the same size.";
break;
}
}
}
}
else
{
errors["InputWorkspaces"] = "Input workspaces must be given";
}

m_numWorkspaces = m_inputWorkspaces.size();

Expand Down

0 comments on commit 96afad8

Please sign in to comment.