Skip to content

Commit

Permalink
Added silent removal to workspace group replace handler.
Browse files Browse the repository at this point in the history
Refs #7807
  • Loading branch information
Samuel Jackson committed Aug 28, 2013
1 parent 1a1a52d commit e72a9c3
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions Code/Mantid/Framework/API/src/WorkspaceGroup.cpp
Expand Up @@ -287,18 +287,35 @@ void WorkspaceGroup::workspaceDeleteHandle(Mantid::API::WorkspacePostDeleteNotif
void WorkspaceGroup::workspaceReplaceHandle(Mantid::API::WorkspaceBeforeReplaceNotification_ptr notice)
{
Poco::Mutex::ScopedLock _lock(m_mutex);
bool isObserving = m_observingADS;
if ( isObserving )
observeADSNotifications( false );
std::string newName = notice->object_name();
if(this->contains(newName))
{
bool isObserving = m_observingADS;
if ( isObserving )
observeADSNotifications( false );

//remove any workspace that already exists with the name
this->remove(notice->object_name());
//remove any workspace that already exists with the name
if(this->name() != newName)
{

//replace the object in the group
this->addWorkspace(notice->new_object());
//remove workspace from group
std::vector<Workspace_sptr>::iterator iter = this->m_workspaces.begin();
for(; iter != m_workspaces.end(); ++iter)
{
if((**iter).name() == newName)
{
m_workspaces.erase(iter);
break;
}
}

//replace the object in the group
this->addWorkspace(notice->new_object());
}

if ( isObserving )
observeADSNotifications( true );
if ( isObserving )
observeADSNotifications( true );
}
}

/**
Expand Down

0 comments on commit e72a9c3

Please sign in to comment.