From 5888e23e020ac3fd56a93c75682a216bd7085593 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 16 Jun 2019 19:04:06 +1000 Subject: [PATCH] Do not add window pointing to deleted buffers in the free window list Fixes #2975 --- src/client_manager.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/client_manager.cc b/src/client_manager.cc index a3426a04b..b1d6c6f21 100644 --- a/src/client_manager.cc +++ b/src/client_manager.cc @@ -137,6 +137,7 @@ void ClientManager::remove_client(Client& client, bool graceful, int status) WindowAndSelections ClientManager::get_free_window(Buffer& buffer) { + kak_assert(contains(BufferManager::instance(), &buffer)); auto it = find_if(m_free_windows | reverse(), [&](const WindowAndSelections& ws) { return &ws.window->buffer() == &buffer; }); @@ -153,6 +154,9 @@ WindowAndSelections ClientManager::get_free_window(Buffer& buffer) void ClientManager::add_free_window(std::unique_ptr&& window, SelectionList selections) { + if (not contains(BufferManager::instance(), &window->buffer())) + return; + window->clear_display_buffer(); m_free_windows.push_back({std::move(window), std::move(selections)}); }