Fix buffer deletion logic

'eval -buffer * db' was failing in certain cases
This commit is contained in:
Maxime Coste 2016-02-11 23:07:42 +00:00
parent a7a2e51d52
commit dfe3098b18
2 changed files with 8 additions and 1 deletions

View File

@ -134,6 +134,7 @@ void ClientManager::ensure_no_client_uses_buffer(Buffer& buffer)
if (buf.get() != &buffer)
{
client->context().change_buffer(*buf);
client->set_last_buffer(nullptr);
break;
}
}

View File

@ -1288,8 +1288,14 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func)
func(parser, c);
};
if (*bufnames == "*")
for (auto buffer : BufferManager::instance())
{
// copy buffer list as we might be mutating the buffer list
// in the loop.
Vector<SafePtr<Buffer>> buffers{BufferManager::instance().begin(),
BufferManager::instance().end()};
for (auto buffer : buffers)
context_wrap_for_buffer(*buffer);
}
else
for (auto& name : split(*bufnames, ','))
context_wrap_for_buffer(BufferManager::instance().get_buffer(name));