Ensure ClientManager is always outliving the BufferManager
This commit is contained in:
parent
068ca08b4c
commit
72dc8e6774
|
@ -16,12 +16,22 @@ struct name_not_unique : runtime_error
|
|||
name_not_unique() : runtime_error("buffer name is already in use") {}
|
||||
};
|
||||
|
||||
BufferManager::BufferManager()
|
||||
{
|
||||
kak_assert(ClientManager::has_instance());
|
||||
}
|
||||
|
||||
BufferManager::~BufferManager()
|
||||
{
|
||||
kak_assert(ClientManager::has_instance());
|
||||
|
||||
// delete remaining buffers
|
||||
while (not m_buffers.empty())
|
||||
{
|
||||
ClientManager::instance().ensure_no_client_uses_buffer(*m_buffers.front().get());
|
||||
delete m_buffers.front().get();
|
||||
}
|
||||
}
|
||||
|
||||
void BufferManager::register_buffer(Buffer& buffer)
|
||||
{
|
||||
|
@ -62,7 +72,6 @@ void BufferManager::delete_buffer(Buffer& buffer)
|
|||
{ return p.get() == &buffer; });
|
||||
kak_assert(it != m_buffers.end());
|
||||
|
||||
if (ClientManager::has_instance())
|
||||
ClientManager::instance().ensure_no_client_uses_buffer(buffer);
|
||||
|
||||
m_buffers.erase(it);
|
||||
|
@ -106,7 +115,6 @@ void BufferManager::clear_buffer_trash()
|
|||
|
||||
// Do that again, to be tolerant in some corner cases, where a buffer is
|
||||
// deleted during its creation
|
||||
if (ClientManager::has_instance())
|
||||
ClientManager::instance().ensure_no_client_uses_buffer(*buffer);
|
||||
|
||||
delete buffer;
|
||||
|
|
|
@ -16,6 +16,7 @@ public:
|
|||
using BufferList = Vector<SafePtr<Buffer>>;
|
||||
using iterator = BufferList::const_iterator;
|
||||
|
||||
BufferManager();
|
||||
~BufferManager();
|
||||
|
||||
void register_buffer(Buffer& buffer);
|
||||
|
|
Loading…
Reference in New Issue
Block a user