From 67849f2db7df141c09f5b26205d76fea2fcbd583 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 2 Mar 2016 20:27:47 +0000 Subject: [PATCH] BufferManager should outlive ClientManager in the end If not, clients end up keeping references on a buffer while it it being deleted. --- src/buffer_manager.cc | 10 +--------- src/buffer_manager.hh | 1 - src/main.cc | 4 ++-- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/buffer_manager.cc b/src/buffer_manager.cc index 3398be34..9568c33e 100644 --- a/src/buffer_manager.cc +++ b/src/buffer_manager.cc @@ -16,21 +16,13 @@ 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()); + kak_assert(not 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) diff --git a/src/buffer_manager.hh b/src/buffer_manager.hh index 17388c92..014d241e 100644 --- a/src/buffer_manager.hh +++ b/src/buffer_manager.hh @@ -16,7 +16,6 @@ public: using BufferList = Vector>; using iterator = BufferList::const_iterator; - BufferManager(); ~BufferManager(); void register_buffer(Buffer& buffer); diff --git a/src/main.cc b/src/main.cc index b1c5a7df..1b6f38cb 100644 --- a/src/main.cc +++ b/src/main.cc @@ -463,8 +463,8 @@ int run_server(StringView session, StringView init_command, HighlighterRegistry highlighter_registry; DefinedHighlighters defined_highlighters; FaceRegistry face_registry; - ClientManager client_manager; BufferManager buffer_manager; + ClientManager client_manager; register_options(); register_env_vars(); @@ -590,8 +590,8 @@ int run_filter(StringView keystr, StringView commands, ConstArrayView