Skip to content

Commit

Permalink
Re #6198. Update InstrumentView usage of mapping method.
Browse files Browse the repository at this point in the history
I restored the documented exception throwing behaviour after checking that
every place that calls the method catches the exception. Not sure when/why
that behaviour was changed, but this avoids the risk of accessing an
invalid iterator.
  • Loading branch information
RussellTaylor committed Sep 18, 2013
1 parent c96632a commit f09ccaf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ m_sampleActor(NULL)
InstrumentActor::~InstrumentActor()
{
saveSettings();
delete m_detid2index_map;
}

/** Used to set visibility of an actor corresponding to a particular component
Expand Down Expand Up @@ -314,7 +313,13 @@ IDetector_const_sptr InstrumentActor::getDetector(size_t i) const
*/
size_t InstrumentActor::getWorkspaceIndex(Mantid::detid_t id) const
{
return (*m_detid2index_map)[id];
auto mapEntry = m_detid2index_map.find(id);
if ( mapEntry == m_detid2index_map.end() )
{
throw Kernel::Exception::NotFoundError("Detector ID not in workspace",id);
}

return mapEntry->second;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ class InstrumentActor: public QObject, public GLActor
/// Flag to show the guide and other components. Loaded and saved in settings.
bool m_showGuides;

/// Pointer to the workspace's detector ID to workspace index map
Mantid::detid2index_map *m_detid2index_map;
/// The workspace's detector ID to workspace index map
Mantid::detid2index_map m_detid2index_map;

/// All det ids in the instrument in order of pickIDs, populated by Obj..Actor constructors
mutable std::vector<Mantid::detid_t> m_detIDs;
Expand Down

0 comments on commit f09ccaf

Please sign in to comment.