Obtain a new window for a client before releasing the current one

Creating a window potentially runs hooks, which themselves could
trigger shell evaluation, which could handle urgent input events
such as a resize, while waiting for the shell to finish. When that
happens, the client had a temporarily null window as it had already
released its own window.

Fixes #2225
This commit is contained in:
Maxime Coste 2018-07-25 21:23:22 +10:00
parent 47666ba20b
commit 7905382b74

View File

@ -175,10 +175,10 @@ void Client::change_buffer(Buffer& buffer)
auto& client_manager = ClientManager::instance();
m_window->options().unregister_watcher(*this);
m_window->set_client(nullptr);
WindowAndSelections ws = client_manager.get_free_window(buffer);
client_manager.add_free_window(std::move(m_window),
std::move(context().selections()));
WindowAndSelections ws = client_manager.get_free_window(buffer);
m_window = std::move(ws.window);
m_window->set_client(this);
m_window->options().register_watcher(*this);