Run WinClose hook before putting the window into trash
This commit is contained in:
parent
0b9164e7bc
commit
8135a44c6c
|
@ -50,13 +50,13 @@ void BufferManager::delete_buffer(Buffer& buffer)
|
||||||
auto it = find_if(m_buffers, [&](auto& p) { return p.get() == &buffer; });
|
auto it = find_if(m_buffers, [&](auto& p) { return p.get() == &buffer; });
|
||||||
kak_assert(it != m_buffers.end());
|
kak_assert(it != m_buffers.end());
|
||||||
|
|
||||||
|
buffer.on_unregistered();
|
||||||
|
|
||||||
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())
|
if (ClientManager::has_instance())
|
||||||
ClientManager::instance().ensure_no_client_uses_buffer(buffer);
|
ClientManager::instance().ensure_no_client_uses_buffer(buffer);
|
||||||
|
|
||||||
buffer.on_unregistered();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer* BufferManager::get_buffer_ifp(StringView name)
|
Buffer* BufferManager::get_buffer_ifp(StringView name)
|
||||||
|
@ -99,19 +99,6 @@ void BufferManager::backup_modified_buffers()
|
||||||
|
|
||||||
void BufferManager::clear_buffer_trash()
|
void BufferManager::clear_buffer_trash()
|
||||||
{
|
{
|
||||||
for (auto& buffer : m_buffer_trash)
|
|
||||||
{
|
|
||||||
// Do that again, to be tolerant in some corner cases, where a buffer is
|
|
||||||
// deleted during its creation
|
|
||||||
if (ClientManager::has_instance())
|
|
||||||
{
|
|
||||||
ClientManager::instance().ensure_no_client_uses_buffer(*buffer);
|
|
||||||
ClientManager::instance().clear_window_trash();
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_buffer_trash.clear();
|
m_buffer_trash.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -158,7 +158,11 @@ void ClientManager::ensure_no_client_uses_buffer(Buffer& buffer)
|
||||||
{ return &ws.window->buffer() == &buffer; });
|
{ return &ws.window->buffer() == &buffer; });
|
||||||
|
|
||||||
for (auto it = end; it != m_free_windows.end(); ++it)
|
for (auto it = end; it != m_free_windows.end(); ++it)
|
||||||
m_window_trash.push_back(std::move(it->window));
|
{
|
||||||
|
auto& win = it->window;
|
||||||
|
win->run_hook_in_own_context(Hook::WinClose, win->buffer().name());
|
||||||
|
m_window_trash.push_back(std::move(win));
|
||||||
|
}
|
||||||
|
|
||||||
m_free_windows.erase(end, m_free_windows.end());
|
m_free_windows.erase(end, m_free_windows.end());
|
||||||
}
|
}
|
||||||
|
|
|
@ -275,6 +275,7 @@ void edit(const ParametersParser& parser, Context& context, const ShellContext&)
|
||||||
|
|
||||||
if (buffer != current_buffer)
|
if (buffer != current_buffer)
|
||||||
context.change_buffer(*buffer);
|
context.change_buffer(*buffer);
|
||||||
|
buffer = &context.buffer(); // change_buffer hooks might change the buffer again
|
||||||
|
|
||||||
if (parser.get_switch("fifo") and not parser.get_switch("scroll"))
|
if (parser.get_switch("fifo") and not parser.get_switch("scroll"))
|
||||||
context.selections_write_only() = { *buffer, Selection{} };
|
context.selections_write_only() = { *buffer, Selection{} };
|
||||||
|
|
|
@ -39,7 +39,6 @@ Window::Window(Buffer& buffer)
|
||||||
|
|
||||||
Window::~Window()
|
Window::~Window()
|
||||||
{
|
{
|
||||||
run_hook_in_own_context(Hook::WinClose, buffer().name());
|
|
||||||
options().unregister_watcher(*this);
|
options().unregister_watcher(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ private:
|
||||||
void on_option_changed(const Option& option) override;
|
void on_option_changed(const Option& option) override;
|
||||||
DisplaySetup compute_display_setup(const Context& context) const;
|
DisplaySetup compute_display_setup(const Context& context) const;
|
||||||
|
|
||||||
|
friend class ClientManager;
|
||||||
void run_hook_in_own_context(Hook hook, StringView param,
|
void run_hook_in_own_context(Hook hook, StringView param,
|
||||||
String client_name = "");
|
String client_name = "");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user