Fix write_all_buffers when BufWrite... hooks create/delete buffers
The buffer list can be mutated during iteration, so it is no safe to directly iterate on the BufferManager, we need to first create our own copy of the buffer list. Fixes #935
This commit is contained in:
parent
b884b499dd
commit
8f2c6eb586
|
@ -340,7 +340,12 @@ const CommandDesc write_cmd = {
|
|||
|
||||
void write_all_buffers()
|
||||
{
|
||||
// Copy buffer list because hooks might be creating/deleting buffers
|
||||
Vector<SafePtr<Buffer>> buffers;
|
||||
for (auto& buffer : BufferManager::instance())
|
||||
buffers.emplace_back(buffer.get());
|
||||
|
||||
for (auto& buffer : buffers)
|
||||
{
|
||||
if ((buffer->flags() & Buffer::Flags::File) and buffer->is_modified()
|
||||
and !(buffer->flags() & Buffer::Flags::ReadOnly))
|
||||
|
|
Loading…
Reference in New Issue
Block a user