BufferManager: Support missing ClientManager

This commit is contained in:
Maxime Coste 2018-02-18 14:50:24 +11:00
parent 10c6c59a26
commit d9cddf41f2

View File

@ -21,6 +21,7 @@ BufferManager::~BufferManager()
buffer->on_unregistered(); buffer->on_unregistered();
// Make sure not clients exists // Make sure not clients exists
if (ClientManager::has_instance())
ClientManager::instance().clear(); ClientManager::instance().clear();
} }
@ -55,6 +56,7 @@ void BufferManager::delete_buffer(Buffer& buffer)
m_buffer_trash.emplace_back(std::move(*it)); m_buffer_trash.emplace_back(std::move(*it));
m_buffers.erase(it); m_buffers.erase(it);
if (ClientManager::has_instance())
ClientManager::instance().ensure_no_client_uses_buffer(buffer); ClientManager::instance().ensure_no_client_uses_buffer(buffer);
buffer.on_unregistered(); buffer.on_unregistered();
@ -105,8 +107,11 @@ void BufferManager::clear_buffer_trash()
{ {
// Do that again, to be tolerant in some corner cases, where a buffer is // Do that again, to be tolerant in some corner cases, where a buffer is
// deleted during its creation // deleted during its creation
if (ClientManager::has_instance())
{
ClientManager::instance().ensure_no_client_uses_buffer(*buffer); ClientManager::instance().ensure_no_client_uses_buffer(*buffer);
ClientManager::instance().clear_window_trash(); ClientManager::instance().clear_window_trash();
}
buffer.reset(); buffer.reset();
} }