Skip to content

Commit

Permalink
Updated rename algorithms so they don't allow using already existing
Browse files Browse the repository at this point in the history
workspace names.

Refs #7309
  • Loading branch information
arturbekasov committed Jul 25, 2013
1 parent d48b218 commit ddd7953
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Algorithms/src/RenameWorkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ using namespace API;
void RenameWorkspace::init()
{
declareProperty(new WorkspaceProperty<Workspace> ("InputWorkspace", "", Direction::Input));
declareProperty(new WorkspaceProperty<Workspace> ("OutputWorkspace", "", Direction::Output));
declareProperty(new WorkspaceProperty<Workspace> ("OutputWorkspace", "", Direction::Output, UniqueMode::Unique));
}

/** Executes the algorithm
Expand Down
8 changes: 7 additions & 1 deletion Code/Mantid/Framework/Algorithms/src/RenameWorkspaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ void RenameWorkspaces::exec()
}
}


size_t nWs = inputWsName.size();
if( newWsName.size() > 0) {
// We are using a list of new names
Expand All @@ -111,6 +110,13 @@ void RenameWorkspaces::exec()
}
}

// Check that all of the new names are unique
for(auto it = newWsName.begin(); it != newWsName.end(); it++)
{
if(AnalysisDataService::Instance().doesExist((*it)))
throw std::invalid_argument("Workspace with the name \"" + (*it) + "\" already exists");
}

// loop over array and rename each workspace
for (size_t i=0; i<nWs; ++i)
{
Expand Down

0 comments on commit ddd7953

Please sign in to comment.