destroy buffer manager first but clear clients before destroying buffers.

Fixes #612
This commit is contained in:
Maxime Coste 2016-03-03 13:55:35 +00:00
parent f16bb36f41
commit b5b5b82c70
4 changed files with 12 additions and 3 deletions

View File

@ -18,7 +18,8 @@ struct name_not_unique : runtime_error
BufferManager::~BufferManager()
{
kak_assert(not ClientManager::has_instance());
// Make sure not clients exists
ClientManager::instance().clear();
// delete remaining buffers
while (not m_buffers.empty())

View File

@ -14,6 +14,12 @@ namespace Kakoune
ClientManager::ClientManager() = default;
ClientManager::~ClientManager()
{
clear();
}
void ClientManager::clear()
{
m_free_windows.clear();
// So that clients destructor find the client manager empty
// so that local UI does not fork.
ClientList clients = std::move(m_clients);

View File

@ -33,6 +33,8 @@ public:
bool empty() const { return m_clients.empty(); }
size_t count() const { return m_clients.size(); }
void clear();
void ensure_no_client_uses_buffer(Buffer& buffer);
WindowAndSelections get_free_window(Buffer& buffer);

View File

@ -463,8 +463,8 @@ int run_server(StringView session, StringView init_command,
HighlighterRegistry highlighter_registry;
DefinedHighlighters defined_highlighters;
FaceRegistry face_registry;
BufferManager buffer_manager;
ClientManager client_manager;
BufferManager buffer_manager;
register_options();
register_env_vars();
@ -590,8 +590,8 @@ int run_filter(StringView keystr, StringView commands, ConstArrayView<StringView
ShellManager shell_manager;
CommandManager command_manager;
RegisterManager register_manager;
BufferManager buffer_manager;
ClientManager client_manager;
BufferManager buffer_manager;
register_options();
register_env_vars();